Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to use LEFT Justified in cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
dyobik

New User


Joined: 04 Nov 2006
Posts: 5

PostPosted: Mon Nov 06, 2006 2:59 pm    Post subject: How to use LEFT Justified in cobol
Reply with quote

hi,

i want to know how to use left justified in cobol?

they say that i should use unstring but i cant still get it.
Back to top
View user's profile Send private message

Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1230
Location: Israel

PostPosted: Mon Nov 06, 2006 4:05 pm    Post subject:
Reply with quote

Quick and dirty:
Code:
INSPECT input-field REPLACING LEADING SPACE BY HIGH-VALUE
UNSTRING input-field DELIMITED BY ALL HIGH-VALUE         
    INTO garbage-field output-field

input-field is the input field. It contains data somewhere in the middle or on the right side of the field.
output-field will contain the same data but left justified.
As the delimiter is H-V, all that's on the left of H-V is considered 1st word. All that's right of H-V is 2nd word. garbage-field is necessary to contain the 1st word (which is empty, but we don't care).
INSPECT and UNSTRING are heavy commands. If you know you have to use them 20 million times, beware of the CPU usage!
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Mon Nov 06, 2006 4:19 pm    Post subject:
Reply with quote

IF can't we use the 'JUST LEFT' when you decalare the field in the Workign storage?

~Vamsi
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1230
Location: Israel

PostPosted: Mon Nov 06, 2006 4:34 pm    Post subject:
Reply with quote

JUST LEFT does not exist. It is the default for all PIC X(n) fields.
Only JUST RIGHT can be used to alter the default.

It has meaning only when you move a small field into a large field.
The small field will be placed on the left or right side of the large field.
The rest will be padded with spaces.
If the small field contains spaces, they will stay as they were.
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Mon Nov 06, 2006 4:44 pm    Post subject:
Reply with quote

Thanks Marso.

I thought since there exits 'JUST RIGHT', there would be 'JUST LEFT'.
Thanks for your clarification.

~Vamsi
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1230
Location: Israel

PostPosted: Mon Nov 06, 2006 5:53 pm    Post subject:
Reply with quote

No problem. On second thought, this option is certainly quicker and less dirty:
Code:
MOVE 0 TO counter
INSPECT input-field TALLYING counter FOR LEADING SPACE
MOVE input-field (counter + 1 :) TO output-field

Now, it will work even when there is no leading space, the previous method did not.
The MOVE will be faster than the UNSTRING, that's for sure.
No need for the garbage-field either.
In the whole I would use this method.
Note that initializing the counter before the INSPECT is a must.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 2 Tue May 09, 2017 6:31 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us