IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Group elements using ICETOOL


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 97
Location: India

PostPosted: Fri Apr 14, 2017 11:01 am
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 14, 2017 12:04 pm
Reply with quote

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
View user's profile Send private message
Learncoholic

New User


Joined: 20 Sep 2007
Posts: 97
Location: India

PostPosted: Fri Apr 14, 2017 3:32 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Shift left VB record without x00 endi... DFSORT/ICETOOL 11
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Compare latest 2 rows of a table usin... DB2 1
Search our Forums:

Back to Top