View previous topic :: View next topic
Author
Message
itjagadesh New User Joined: 05 Dec 2006Posts: 89 Location: chennai
Team,
I have following requirement and need to do thru any of utilities.
Input file - Having LRECL 80 having employee number.
But input file record will have variable employee number (some record will have 2 employee num some of them have 3 etc separated by comma)
Ex
Input file having 3 record
123456,23456,45678,,,,,,,,,,,,,,,,,
456789,12345,,,,,,,,,,,,,,,,,,,,,,,,,,,
345677,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Output file should be like below
123456,23456,45678
456789,12345
345677
ie) i need to remove lall the comma ',' into spaces only at the end of each record.
Any utilities like sort ,fileaid should be fine.
Thanks
Jagadesh
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Assuming your input file has RECFM=FB and your account numbers have a maximum of 6 digits, you can use a DFSORT job like the following to do what you asked for:
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
123456,23456,45678,,,,,,,,,,,,,,,,,
456789,12345,,,,,,,,,,,,,,,,,,,,,,,,,,,
345677,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,
PARSE=(%01=(ENDBEFR=C',',FIXLEN=7),
%02=(ENDBEFR=C',',FIXLEN=7),
%03=(ENDBEFR=C',',FIXLEN=7)),
BUILD=(%01,%02,%03)),
IFTHEN=(WHEN=INIT,BUILD=(1,21,SQZ=(SHIFT=LEFT,MID=C',')))
/*
Back to top
itjagadesh New User Joined: 05 Dec 2006Posts: 89 Location: chennai
Thanks Much Frank .
Everything looks good except below one.
Comma (') missing in between employee number .
Below is the output coming now
1234562345645678
45678912345
345677
we are expecting in below format (ie need to remove comma only at end of all the records)
123456,23456,45678
456789,12345
345677
Please help me .
Thanks
Jagadesh
Back to top
gcicchet Senior Member Joined: 28 Jul 2006Posts: 1702 Location: Australia
Hi,
are you sure you have used exactly what Frank posted, I tried it and it works fine for me.
I'm also sure Frank would have tested it before posting his solution.
Gerry
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Jagadesh,
Yes, I tested my solution and it works as expected, so you must have changed something or have something different from what you said.
Quote:
Comma (') missing in between employee number .
That looks like an apostrophe, not a comma. Do you actually have an apostrophe as the delimiter? That would certainly make a difference.
At any rate, I thought of a better solution, so try this one:
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
123456,23456,45678,,,,,,,,,,,,,,,,,
456789,12345,,,,,,,,,,,,,,,,,,,,,,,,,,,
345677,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC BUILD=(1,80,SQZ=(SHIFT=LEFT,MID=C',',PREBLANK=C','))
/*
SORTOUT has:
Code:
123456,23456,45678
456789,12345
345677
If you actually have an apostrophe as the delimiter, use PREBLANK=C'''' instead of PREBLANK=C','.
If you still can't get it to work for you, show your complete JES log so I can figure out what's different for you.
Back to top
itjagadesh New User Joined: 05 Dec 2006Posts: 89 Location: chennai
Frank ,
Sorry for my late response.
First solution itself working fine for me. I gave the input account number in wrong format thats why not working. I corrected my input records and ran with first solution (parse ) and working fine.
Thanks much for your quick help.
Regards
Jagadesh
Back to top
Please enable JavaScript!