how to left justify strings in a file.



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

how to left justify strings in a file.

Postby supriya saraswat » Mon Jul 28, 2008 5:41 pm

i have strings in my file which are right justified.i want to make them left justified..
how can i do that..
supriya saraswat
 
Posts: 21
Joined: Mon Jul 07, 2008 3:24 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how to left justify strings in a file.

 

Re: how to left justify strings in a file.

Postby dick scherrer » Mon Jul 28, 2008 10:09 pm

Hello,

Please post a few examples of your existing data and what you want for the output. If there are multiple strings in the same record, show this also.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: how to left justify strings in a file.

Postby supriya saraswat » Tue Jul 29, 2008 10:37 am

say we have a file in which 2 fields are present.

product cost
abc 24.00
def 35.50

here in case of numeric data type all the digits are right justified.
we want to make them rigth jaustified..

how can it be done.
sorry i mentioned string previously.
supriya saraswat
 
Posts: 21
Joined: Mon Jul 07, 2008 3:24 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how to left justify strings in a file.

Postby dick scherrer » Tue Jul 29, 2008 11:51 am

Hello,

sorry i mentioned string previously.
Not to worry :)

we want to make them rigth jaustified..
Left maybe? Tough day on the keyboard ;)

To do what you want you could count (tally) the leading spaces in each amount and then using reference modification create a left-justified value. The length of the reference modified move would be the length of the amount field minus the leading spaces.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: how to left justify strings in a file.

Postby supriya saraswat » Wed Jul 30, 2008 12:17 pm

thanks for above information but will you please explain it in the form of code.
supriya saraswat
 
Posts: 21
Joined: Mon Jul 07, 2008 3:24 pm
Has thanked: 0 time
Been thanked: 0 time

Re: how to left justify strings in a file.

Postby jayind » Wed Jul 30, 2008 5:38 pm

Hi supriya saraswat,

I have another suggestion.. please try this..

Move the amount field (edited) to alphanumeric as the alphanumeric is left justified.. Try this and let me know whether it worked...

Regards,
jayind
jayind
 
Posts: 62
Joined: Wed Apr 23, 2008 1:37 pm
Location: Chennai, India
Has thanked: 0 time
Been thanked: 0 time

Re: how to left justify strings in a file.

Postby dick scherrer » Thu Jul 31, 2008 12:34 am

Hello,

Move the amount field (edited) to alphanumeric as the alphanumeric is left justified..
Did you test this before posting?

If not, it is best to test "solutions" before posting them. If yes, it would be good to post the definition variable fields used for the test.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post