pravinj
New User
Joined: 10 Jun 2008 Posts: 24 Location: india
|
|
|
|
Hello... I have a requirement and I am seeing if we can do that through DFSORT option. I tried using SORT but wasn't able to arrive at the output.
Requirement is as follows,
Input file:
Code: |
XXXX 02
YYYYY 01
ZZZZ 06
XXXX 01
ZZZZ 02 |
Expected output:
Code: |
XXXX 02 03
YYYY 01 01
ZZZZ 06 08
XXXX 01 03
ZZZZ 02 08 |
Here from the requirement, you could see that the sum of a group is being listed at the end of each record. For XXXX, there are 2 records summing up to 03. The o/p to be written as XXXX 02 03 and XXXX 01 03.
Can you please let me know if it's possible and if so, share some samples or the code for the requirement. |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
pravinj,
Use the following DFSORT JCL which will give you the desired results. I assumed that your input is FB and LRECL=80
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//INA DD *
XXXX 02
YYYY 01
ZZZZ 06
XXXX 01
ZZZZ 02
//INB DD *
XXXX 02
YYYY 01
ZZZZ 06
XXXX 01
ZZZZ 02
//SORTOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS F1=INA,FIELDS=(1,4,A)
JOINKEYS F2=INB,FIELDS=(1,4,A)
JOIN UNPAIRED
REFORMAT FIELDS=(F1:1,8,F2:6,2,F1:11,78)
SORT FIELDS=(81,8,CH,A)
OUTREC BUILD=(1,80)
//*
//JNF1CNTL DD *
INREC OVERLAY=(81:SEQNUM,8,ZD)
//*
//JNF2CNTL DD *
SUM FIELDS=(6,2,ZD)
//* |
|
|