What I would need is to sum up the field which starts with 6 from position 19 to 28 (VB considered), basically sum up +000031900 , +000186300 and +005208900 and add it at position 92 of length 12 including the sign to the end of the trailer record $$ABCEOF after |0000000156| which ends at position 91(VB considered). Also add a pipe delimiter at the end.
So my output should be
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
Can you run this and post the sysout from the step please?
Code:
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
Nothing to do with the solution, just for your SORT level
/*
//SORTOUT DD DUMMY
//SYSIN DD *
OPTION COPY
/*
In general, you will pre-pend your records, temporarily, with a zero value, put the actual value there for your "6" records, then place that in the correct location on the trailer and drop the pre-pended bytes.
Specifics depend on your DFSORT level, which we know when you post the above.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
sudib19 wrote:
What I would need is to sum up the field which starts with 6 from position 19 to 28 (VB considered), basically sum up +000031900 , +000186300 and +005208900 and add it at position 92 of length 12 including the sign to the end of the trailer record $$ABCEOF after |0000000156| which ends at position 91(VB considered). Also add a pipe delimiter at the end.
sudib19,
From your sample data, the records which start with 6 have the amount fields start at 17 which would make them start at position 21 in a VB file. So is your data that you show correct or your description?
Also do you have multiple Trailer records $$ABCEOF or just final one?
That was my bad.. bad indentation... it starts at 15 which would make them start at position 19 in the VB file and has a length of 10 including the sign.
There is just one trailer record $$ABCEOF in which I want to put the sum of the amount field of the records which start with 6.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
sudib19 wrote:
That was my bad.. bad indentation... it starts at 15 which would make them start at position 19 in the VB file and has a length of 10 including the sign.
There is just one trailer record $$ABCEOF in which I want to put the sum of the amount field of the records which start with 6.
Thanks
sudib19,
Try this
1. use the same input file twice for Joinkeys INA and INB and match the keys we create after RDW.
2. Code JNF1CNTL to build=(RDW,8 spaces, data record stat pos) for all the records using IFTHEN=(WHEN=INIT. Using another IFTHEN=(13,8,ch,eq,C'$$ABCEOF'),overlay=(5;13,8).
3. Code JNF2CNTL with INCLUDE COND=((5,1,CH,EQ,C'6',OR,5,8,CH,EQ,C'$$ABCEOF') and use INREC to BUILD=(rdw,C'$$ABCEOF',19,10,SFF,PD,LENGTH=6)
Code sum fields=(13,6,pd)
4.After the JOIN you have the summed value in PD format on the last record. Now using INREC IFTHEN=(WHEN=(11,8,CH,EQ,C'$$ABCEOF'),OVERLAY at position 98 the value at 5 for a length of 6 bytes using the EDIT mask EDIT=(STTTTTTTTTTT),SIGNS=(+,-),C'|')).
5. Using OUTREC BUILD remove the temp fields BUILD=(1,4,11) should give you the desired results.