Page 1 of 1

Reformatting file using Syncsort

PostPosted: Thu Dec 18, 2008 3:28 am
by Marina Lozovatsky
Is that possible to get rid of spaces and shift data up? (please see example below)
PRO   00001  00001  AAA                           
PRO   00001  00001  BBB                           
PRO   00001  00001  AAA       
PRO   00001  00001  AAA                       
                                     CTR   00001  00001  CCC
                                     CTR   00001  00001  BBB
                                     CTR   00001  00001  BBB
                                     CTR   00001  00001  AAA   

I also need to sum some fields and get something like:
PRO   00001  00003  AAA            CTR   00001  00001  CCC       
PRO   00001  00001  BBB            CTR   00002  00002  BBB       
                                   CTR   00001  00001  AAA       


Thanks!

Re: Reformatting file using Syncsort

PostPosted: Thu Dec 18, 2008 4:02 am
by dick scherrer
Hello Marina and welcome to the forum,

Please review your post and let us know if the output is exactly the way it is needed.

Is there some reason that the aaa,bbb,ccc are not in sequence on the right-hand side of the output?

Re: Reformatting file using Syncsort

PostPosted: Thu Dec 18, 2008 4:37 am
by Marina Lozovatsky
Thank you for reply, it could be in sequence order like this:
    PRO   00001  00003  AAA            CTR   00001  00001  AAA     
    PRO   00001  00001  BBB            CTR   00001  00002  BBB       
                                       CTR   00001  00001  CCC       

but PRO records on the left are not related to CTR records on the right.

Re: Reformatting file using Syncsort

PostPosted: Thu Feb 05, 2009 3:12 am
by Alissa Margulies
Try the following SyncSort for z/OS job. I believe it will provide you with the desired results:
//S1    EXEC PGM=SORT                                             
//PRO     DD DISP=(,PASS),DSN=&&PRO,UNIT=SYSDA,SPACE=(TRK,1)     
//CTR     DD DISP=(,PASS),DSN=&&CTR,UNIT=SYSDA,SPACE=(TRK,1)     
//SYSOUT  DD SYSOUT=*                                         
//SORTIN  DD *                                             
PRO   00001  00001  AAA                                     
PRO   00001  00001  BBB                                     
PRO   00001  00001  AAA                                     
PRO   00001  00001  AAA                                     
                                     CTR   00001  00001  CCC
                                     CTR   00001  00001  BBB
                                     CTR   00001  00001  BBB
                                     CTR   00001  00001  AAA
//SYSIN   DD *                                           
   INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'PRO'),                 
   OVERLAY=(44:5C'0',51:5C'0')),                         
   IFTHEN=(WHEN=(38,3,CH,EQ,C'CTR'),                     
   OVERLAY=(14:5C'0'))                                   
   SORT FIELDS=(1,4,CH,A,21,4,CH,A,38,3,CH,A,58,3,CH,A)   
   DUPKEYS SUM=(14,5,ZD,44,5,ZD,51,5,ZD)                 
   OUTFIL FNAMES=PRO,INCLUDE=(1,3,CH,EQ,C'PRO'),         
   OUTREC=(1,24,SEQNUM,8,ZD)                             
   OUTFIL FNAMES=CTR,SAVE,OUTREC=(38,24,SEQNUM,8,ZD)     
//******************************************************
//S2     EXEC PGM=SORT                                 
//SYSOUT   DD SYSOUT=*                                 
//SORTOUT  DD SYSOUT=*                                 
//SORTJNF1 DD DISP=SHR,DSN=&&PRO                       
//SORTJNF2 DD DISP=SHR,DSN=&&CTR                       
//SYSIN    DD *                                         
  JOINKEYS FILE=F1,FIELDS=(25,8,A)                     
  JOINKEYS FILE=F2,FIELDS=(25,8,A)                     
  JOIN UNPAIRED                                         
  REFORMAT FIELDS=(F1:1,24,F2:1,24),FILL=X'40'         
  SORT FIELDS=COPY
  OUTREC BUILD=(1,24,38:25,24)     
/*                               

Here is the output produced from the above jobstream:
PRO   00001  00003  AAA              CTR   00001  00001  AAA
PRO   00001  00001  BBB              CTR   00002  00002  BBB
                                     CTR   00001  00001  CCC