Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
hiravibk wrote: |
The trailer XF9 will have the total number of transactions in the input file in position 24. The position 38 in trailer will have sum of all the debits in the input file in 9(13)V99. The position 52 in trailer will have sum of all the credits in the input file with 9(13)V99. |
Aren't the totals overlaying each other? If the debits total starts in position 38 and needs 15 bytes it will end up at pos 52 and you want the total of credits to start at the same position? Assuming that these are typos and the output file lrecl is 80 bytes the following DFSORT JCL will give you the desired results.
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
----+----1----+----2----+----3----+----4----+----5----+----6----+----7-
//SORTIN DD *
1234567890123 000000000002500 DEBIT USER1 2012-01-18-11:08:54.567890
1234567890124 000000000003500 CREDITUSER2 2012-01-18-12:08:54.567890
1234567890125 000000000002500 DEBIT USER3 2012-01-18-13:08:54.567890
1234567890126 000000000002500 CREDITUSER4 2012-01-18-14:08:54.567890
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:2C'+000000000000000',48,2,X)),
IFTHEN=(WHEN=INIT,FINDREP=(STARTPOS=113,
INOUT=(C'01',C'JAN',C'02',C'FEB',C'03',C'MAR',C'04',C'APR',
C'05',C'MAY',C'06',C'JUN',C'07',C'JUL',C'08',C'AUG',
C'09',C'SEP',C'10',C'OCT',C'11',C'NOV',C'12',C'DEC'))),
IFTHEN=(WHEN=(31,6,CH,EQ,C'CREDIT'),OVERLAY=(82:15,15)),
IFTHEN=(WHEN=(31,5,CH,EQ,C'DEBIT'),OVERLAY=(97:C'-',15,15))
OUTFIL REMOVECC,
BUILD=(C'SYS1 ',DATE1(-),20:C'XF1 ',DATE1(-),X,15,22,/,
C'SYS1 ',DATE1(-),20:C'XF2 ',DATE1(-),X,37,11,113,3,50,3,/,
C'SYS1 ',DATE1(-),20:C'XF3 ',C'ACCOUNT ',1,13,80:X),
HEADER1=('SYS1',20:'XF0 ',DATE=(4MD-)),
TRAILER1=('SYS1',20:'XF9 ',COUNT=(M11,LENGTH=13),
38:TOT=(97,16,SFF,EDIT=(TTTTTTTTTTTTTTT)),
54:TOT=(81,16,SFF,EDIT=(TTTTTTTTTTTTTTT)))
//* |
The output from the above job is
Code: |
SYS1 XF0 2012-01-19
SYS1 2012-01-19 XF1 2012-01-19 000000000002500 DEBIT
SYS1 2012-01-19 XF2 2012-01-19 USER1 2012-JAN-18
SYS1 2012-01-19 XF3 ACCOUNT 1234567890123
SYS1 2012-01-19 XF1 2012-01-19 000000000003500 CREDIT
SYS1 2012-01-19 XF2 2012-01-19 USER2 2012-JAN-18
SYS1 2012-01-19 XF3 ACCOUNT 1234567890124
SYS1 2012-01-19 XF1 2012-01-19 000000000002500 DEBIT
SYS1 2012-01-19 XF2 2012-01-19 USER3 2012-JAN-18
SYS1 2012-01-19 XF3 ACCOUNT 1234567890125
SYS1 2012-01-19 XF1 2012-01-19 000000000002500 CREDIT
SYS1 2012-01-19 XF2 2012-01-19 USER4 2012-JAN-18
SYS1 2012-01-19 XF3 ACCOUNT 1234567890126
SYS1 XF9 0000000000004 000000000005000 000000000006000
|
|
|