Files



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

Files

Postby mahesh100 » Thu Aug 20, 2009 11:25 pm

Hi,

I need to remove the padded spaces from one of the field.

File layout
two-char x(2)
three-char (3)
name x(35)
indicator 9(1)
indicator 9(1)

Input file

HEADER
IN,IND,INDIA                      ,1,0
GB,GBP,GREAT BRITAIN POUND        ,1,O
TRAILOR


(Remove all the extra spaces in the name field)
Output file:

header
IN,IND,INDIA,1,0
GB,GBP,GREAT BRITIAN POUND,1,0
TRAILOR

Please let me know of any thoughts.

Thanks,
Mahe
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Files

 

Re: Files

Postby mahesh100 » Thu Aug 20, 2009 11:38 pm

INPUT FILE

HEADER
IN.IND,INDIAZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ,0,1
GB,GBP,GREAT BRITAIN POUNDZZZZZZZZZZZZZZZZZZZZZZ,0,1
TRAILOR

zzzzzz --> Blanks

I want to remove all the blanks, So that when character comes to an end, delimit by , and remaining fields.

Thanks,
Mahesh
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Files

Postby dick scherrer » Fri Aug 21, 2009 6:12 am

Hello,

Suggest you become both familiar and comfortable with the the Code tag and the Preview function. Code will preserve alignment and improve readability and should be used for posting code, jcl, data, etc. The Preview function is used so you can see your post as it will appear to the forum rather than what is seen in the Reply editor. Make changes until the appearance is as you want it, then Submit. Do not forget to Submit as the editing will be lost. . .

The sample input data does not match the "file layout". Is the input delimited?
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: Files

Postby mahesh100 » Fri Aug 21, 2009 12:21 pm

Hi,

Yes, The file is delimited by ,

Thanks,
Mahe
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Files

Postby dick scherrer » Sat Aug 22, 2009 12:49 am

Hello,

Then you could UNSTRING the data into separate fields, calculate the length of the name field data, and STRING the individual fields back into a single field for output.
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: Files

Postby mahesh100 » Thu Aug 27, 2009 2:46 pm

Hi,

I was holiday.
I feel even if you string the individual field back into the single field , the output field will still hold the spaces as the output field is declared as x(40).

Probably i could not get your point.

Thanks,
Mahe
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Files

Postby dick scherrer » Fri Aug 28, 2009 3:56 am

Welcome back. . . :)

Yes, there will still be 40 bytes - they do not go away. . . However, after the unstring/string (if done properly), the embedded blanks will be removed.
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: Files

Postby mahesh100 » Mon Aug 31, 2009 6:05 pm

Dick,

Thanks for the info... But still i am thinking on it ,how to use that ...

If any help on that will be great...
I was thinking on the Inspect as well.

Thanks,
Mahe
mahesh100
 
Posts: 12
Joined: Thu Aug 20, 2009 11:11 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Files

Postby dick scherrer » Tue Sep 01, 2009 3:03 am

Hello,

Unless i completely misunderstand what you want to do, inspect will not be of any use. . .

But still i am thinking on it ,how to use that ...
If any help on that will be great...
What is not clear? The input is a "not quite usable" delimited string (because of embedded spaces). If the string is unstrung into several variables, the meaningful length of each component can be calculated (field length minus trailing spaces), and then the values can be strung back together using reference modification, eliminating the unwanted trailing 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


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post