Page 1 of 1

Data patching using DFSORT?

PostPosted: Tue Sep 22, 2009 10:03 pm
by jimscholes
Hi,

I want to patch some data in the master file but have no idea how to do it using SORT/ICETOOL.

Master File A:

0030000123456789....................1E.............. (1000 bytes)
0030000223456789....................2E.............. (1000 bytes)
0030000323456789....................2E.............. (1000 bytes)
0030000423456789....................2E.............. (1000 bytes)
0030000523456789....................1E.............. (1000 bytes)
0030000623456789....................2A.............. (1000 bytes)
where first 16 byte is a unique key value, offset 160-161 contains a S9(2) signed numeric value (stores a counter value)

Work File B:

0030000223456789..........2A....... (200 bytes)
0030000423456789..........1A....... (200 bytes)
0030000523456789..........1C....... (200 bytes)
where first 16 byte is a unique key value, offset 55-56 contains a S9(2) signed numeric value; key in work file B always exists in master file A.

Now, I want to add up the counter value for matching key and replace this value in master file A.

Final output file C looks like

0030000123456789....................1E.............. (1000 bytes)
0030000223456789....................4F.............. (1000 bytes)
0030000323456789....................2E.............. (1000 bytes)
0030000423456789....................3F.............. (1000 bytes)
0030000523456789....................2H.............. (1000 bytes)
0030000623456789....................2A.............. (1000 bytes)

Please help.

Regards,
Jim

Re: Data patching using DFSORT?

PostPosted: Tue Sep 22, 2009 11:46 pm
by skolusu
Jim,

The following JCL will give you the desired results

//STEP0100 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=Your 200 byte work file,DISP=SHR
//SORTOUT  DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE) 
//SYSIN    DD *                                             
  SORT FIELDS=COPY                                         
  OUTREC BUILD=(1,16,161:55,2,1000:X)                       
/*                                                         
//STEP0200 EXEC PGM=SORT                                   
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=Your 1000 byte master file,DISP=SHR
//         DD DSN=&&T1,DISP=SHR                             
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  OPTION NZDPRINT,EQUALS                                   
  SORT FIELDS=(1,16,CH,A)                                   
  SUM FIELDS=(161,2,ZD)                                     
/*                                                         

Re: Data patching using DFSORT?

PostPosted: Wed Sep 23, 2009 1:59 am
by jimscholes
Thanks skolusu. I got the desired results.

After the sum, there are some records that have a new counter value of 0. If I want to have an output file that only contains counter value > 0, can I do it in STEP0200 as well? Or should I have another step to filter out records that have counter value > 0?

Re: Data patching using DFSORT?

PostPosted: Wed Sep 23, 2009 2:22 am
by Frank Yaeger
Yes, you can do it in STEP0200 with an OUTFIL INCLUDE=(...) statement.