Page 1 of 1

Reformat multiple records into single with occurences????

PostPosted: Thu May 23, 2013 10:45 pm
by rmd3003
Hello there. I was curious if it's possible to reformat multiple records with the same key into single one using ICETOOL?
Input file has multiple records with the same key (they can change). No more than 25 records per key.

Output file will have single record per key with occurences (25)

I also need to populate counter on record on output record in position 15

Input file:
-
---+----1----+----2----+----3----+----4----+----5
AAAA00001         R01X001                       
AAAA00001         R01X002                       
AAAA00222         R02X001                       
AAAA00222         R02X002                       
AAAA00222         R02X003                       
AAAA33333         R03X001                       
AAAA33333         R03X002                       
AAAA33333         R03X003                       
AAAA33333         R03X004                       
AAAA33333         R03X005   


Output file will be like this:
Counter is highlighted in yellow.
---+----1----+----2----+----3----+----4----+----5----+--
AAAAA00001   002  R01X001 R01X002                       
AAAAA00222   003  R02X001 R02X002 R02X003               
AAAAA33333   005  R03X001 R03X002 R03X003 R03X004 R03X004


If it's possible maybe somebody has similar code to show me.
Thank you very much in advance.....

BTW - SYNCSORT FOR Z/OS 1.4.0.1R

Re: Reformat multiple records into single with occurences???

PostPosted: Fri May 24, 2013 5:11 am
by BillyBoyo
Well, there is a similar question today in the DFSORT forum on the Sister site, http://ibmmainframes.com You'll need to use SPLICE with several IFTHENs (25 at least to arrange the data, perhaps a few more to do the count).

Re: Reformat multiple records into single with occurences???

PostPosted: Sat May 25, 2013 4:27 pm
by Thampy
Please find below the Syncsort JCL for the single record per key with occurences (5). You can modify the jcl to add another 20 IFTHEN's to suit your requirement
The OUTFIL statement has to be modfied to the record length you are looking for

//STEP010 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
AAAA00001 R01X001
AAAA00001 R01X002
AAAA00222 R02X001
AAAA00222 R02X002
AAAA00222 R02X003
AAAA33333 R03X001
AAAA33333 R03X002
AAAA33333 R03X003
AAAA33333 R03X004
AAAA33333 R03X005
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC IFTHEN=(WHEN=INIT,OVERLAY=(15:C'001',28:8Z,36:8Z,
44:8Z,52:8Z,
300:SEQNUM,3,ZD,RESTART=(1,9))),
IFTHEN=(WHEN=(300,3,ZD,EQ,2),OVERLAY=(28:20,8,20:8Z)),
IFTHEN=(WHEN=(300,3,ZD,EQ,3),OVERLAY=(36:20,8,20:8Z)),
IFTHEN=(WHEN=(300,3,ZD,EQ,4),OVERLAY=(44:20,8,20:8Z)),
IFTHEN=(WHEN=(300,3,ZD,EQ,5),OVERLAY=(52:20,8,20:8Z))
SORT FIELDS=(1,9,CH,A)
SUM FIELDS=(15,3,ZD,20,8,BI,28,8,BI,36,8,BI,44,8,BI,
52,8,BI)
OUTREC FINDREP=(IN=X'00',OUT=X'40')
OUTFIL BUILD=(1,80)


Sample Output
AAAA00001 002 R01X001 R01X002
AAAA00222 003 R02X001 R02X002 R02X003
AAAA33333 005 R03X001 R03X002 R03X003 R03X004 R03X005

Re: Reformat multiple records into single with occurences???

PostPosted: Sun May 26, 2013 8:02 pm
by NicC
As IFTHEN is a sort control keyword modifying the JCL is impossible as it does not have IFTHEN. Presumably you meant modify the sort control cards.

Re: Reformat multiple records into single with occurences???

PostPosted: Tue May 28, 2013 8:07 pm
by rmd3003
Thanks everybody.

Re: Reformat multiple records into single with occurences???

PostPosted: Wed May 29, 2013 12:45 am
by Thampy
I meant modify the SORT control cards to add 20 IFTHEN's. Sorry for the confusion caused.