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: 1219
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: 1219
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: 1219
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
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am
No new posts Cobol list of programs being called biswajit.dattagupta COBOL Programming 5 Tue Nov 01, 2016 2:10 am
No new posts Can sending 5 MB data between cobol p... Kevin Vaz CICS 12 Tue Oct 18, 2016 4:50 pm


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