|
View previous topic :: View next topic
|
| Author |
Message |
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
Hi,
I have the below comma delimited dataset. In spite of this being comma delimited, the fields are not squeezed off spaces. Hence each column have a fixed width.
| Code: |
ABC ,1234,XYZ, KEY-0001,CODE1,MESSAGE
BCD ,2345,UCC, KEY-0002,CODE2,MESSAGE
DF ,4555,CKI, KEY-003,CODE3,MESSAGE
, , , ,CODE5,MESSAGE
ABC ,1425,RBN, KEY=0004,CODE6,MESSAGE
ABD ,4578,NBN, KEY*0005,CODE7,MESSAGE
ABM ,1247,RBO, KEY-0006,CODE2,MESSAGE
, , , ,CODE1,MESSAGE
, , , , ,
CNO ,4578,MNB, KEY-0007,CODE4,MESSAGE
MBO ,1578,CGB, KEY-0007,CODE2,MESSAGE |
I would like to have the O/P as:
| Code: |
ABC ,1234,XYZ, KEY-0001,CODE1,MESSAGE
BCD ,2345,UCC, KEY-0002,CODE2,MESSAGE
DF ,4555,CKI, KEY-003,CODE3,MESSAGE
DF ,4555,CKI, KEY-003,CODE5,MESSAGE
ABC ,1425,RBN, KEY=0004,CODE6,MESSAGE
ABD ,4578,NBN, KEY*0005,CODE7,MESSAGE
ABM ,1247,RBO, KEY-0006,CODE2,MESSAGE
ABM ,1247,RBO, KEY-0006,CODE1,MESSAGE
CNO ,4578,MNB, KEY-0007,CODE4,MESSAGE
MBO ,1578,CGB, KEY-0007,CODE2,MESSAGE |
Basically,
we would check whether the CODE field (5th Column) is spaces or not. If it's spaces, we will remove the record. If it is not, we will update the data from previous record till the code field (5th column). There may be multiple records with only code field(5th column) populated. We have to fill these up from the top record having data populated in the previous fields.
for ease of reference, I am providing below the Field length for each field:
FIELD1: 4
FIELD2: 4
FIELD3: 3
FIELD4: 15
FIELD5: 4
FIELD6: 50
I guess we have to use SPLICE to get the data from above to below fields. Before that we have to Group the data together based on the Blank fields & the row above the Blank fields that contains data for FIELD1 to FIELD4. |
|
| Back to top |
|
 |
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
| WHEN=GROUP with KEYBEGIN, PUSH for the fields you want to propagate. OMIT COND= to get rid of the blank column fives. |
|
| Back to top |
|
 |
Learncoholic
New User
Joined: 20 Sep 2007 Posts: 97 Location: India
|
|
|
|
Thanks Bill, it worked.
I have pasted by code below for improvement suggestions & references:
| Code: |
//STEP01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//INDD01 DD *
ABC ,1234,XYZ, KEY-0001,CODE1,MESSAGE
BCD ,2345,UCC, KEY-0002,CODE2,MESSAGE
DF ,4555,CKI, KEY-003,CODE3,MESSAGE
, , , ,CODE5,MESSAGE
ABC ,1425,RBN, KEY=0004,CODE6,MESSAGE
MOC ,5412,GHT, KEY=0004,CODE2,MESSAGE
ABD ,4578,NBN, KEY*0005,CODE7,MESSAGE
ABM ,1247,RBO, KEY-0006,CODE2,MESSAGE
, , , ,CODE1,MESSAGE
, , , , ,
/*
//SPOOLDD DD SYSOUT=*
//TOOLIN DD *
COPY FROM(INDD01) TO(SPOOLDD) USING(CNT1)
/*
//CNT1CNTL DD *
OMIT COND=(31,1,CH,EQ,C' ')
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(15,15,CH,NE,C' '),
END=(15,15,CH,EQ,C' '),
PUSH=(1:1,30))
/* |
Thanks once again. |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|