|
View previous topic :: View next topic
|
| Author |
Message |
guptae
Moderator

Joined: 14 Oct 2005 Posts: 1209 Location: Bangalore,India
|
|
|
|
Hi All,
I have input file with FB and length 80 bytes like below
| Code: |
C100 Arun, Suresh
C200 John, Sam, Leah.ron, Joe
C300 Raj |
and i want the output in below format
| Code: |
C100 Arun
C100 Suresh
C200 John
C200 Sam
C200 Leah.ron
C200 Joe
C300 Raj |
I tried using Parse but number of name which will be comma separated are unknown. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Well, you need to use PARSE. You may not know how many, but you know the maximum (since your records are fixed-length).
If you use ICETOOL's RESIZE with USING(xxxx) and there PARSE the maximum to fixed positions, you can exclude any blanks on OUTFIL OMIT=/INCLUDE=. |
|
| Back to top |
|
 |
guptae
Moderator

Joined: 14 Oct 2005 Posts: 1209 Location: Bangalore,India
|
|
|
|
Hello Bill,
Thanks for your input.
| Code: |
//TOOLIN DD *
RESIZE FROM(IN) TO(OUT) TOLEN(60) USING(CPY1)
//CPY1CNTL DD *
OPTION COPY
OUTFIL PARSE=(%01=(ENDBEFR=C',',FIXLEN=20),
%02=(ENDBEFR=C',',FIXLEN=20),
%03=(ENDBEFR=C',',FIXLEN=20),
%04=(ENDBEFR=C',',FIXLEN=20)),
BUILD=(%01,/,1,4,%02,/,1,4,%03,/,1,4,%04),INCLUDE=(6,1,CH,NE,C' ')
/* |
But some changes required as output
| Code: |
C100 ARUN
C100 SURESH
C100
C100
C200 JOHN
C200 SAM
C200 LEAH.RON
C200 JOE
C300 RAJ
C300
C300
C300 |
Please advise |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| You need OUTFIL OMIT= for where the name is blank. |
|
| Back to top |
|
 |
guptae
Moderator

Joined: 14 Oct 2005 Posts: 1209 Location: Bangalore,India
|
|
|
|
Tried but not working
| Code: |
//TOOLIN DD *
RESIZE FROM(IN) TO(OUT) TOLEN(60) USING(CPY1)
//CPY1CNTL DD *
OPTION COPY
OUTFIL PARSE=(%01=(ENDBEFR=C',',FIXLEN=20),
%02=(ENDBEFR=C',',FIXLEN=20),
%03=(ENDBEFR=C',',FIXLEN=20),
%04=(ENDBEFR=C',',FIXLEN=20)),
OMIT=(6,1,CH,EQ,C' '),
BUILD=(%01,/,1,4,%02,/,1,4,%03,/,1,4,%04)
/* |
|
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Sorry, just flitting in and out, and didn't look at your code, just the output.
You need to do the PARSE on INREC, to make one long record with all your PARSEd fields on, noting that you need your 1,4 data prefixing each PARSEd field:
| Code: |
| BUILD=(1,4,%01,1,4,%02,1,4,%03....) |
You have 20 for your names, so you need the TOLEN to be 24. This will chop up your records into 24 bytes, and OUTFIL will see them one-at-a-time. So you have an OUTFIL just to do the OMIT (if you need final formatting, inserting of blanks perhaps, you can do it on BUILD in OUTFIL).
Check all the 20 bytes for space, else you can be trapped by a leading blank on a name. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|