Christy
New User
Joined: 17 Nov 2010 Posts: 14 Location: India
|
|
|
|
I have an input file where there is account number and amount field.
The account number is 1-5 and amount field is signed form 7-15 where the sign is in the 15th position.
in the input file there is same account number with different amount value.
that is one account number can be repeated more than once.
i want the sum of the amount in decimal form with sign for each account.
That means if in total there are 4 account numbers like
12345
23456
34567
45678
and the total number of records in input file is 23, after the summing i need a output file with only 4 records.
Corresponding to each account number i need the sum of the amount in signed decimal format.
input file:
23456 00001000 adf
12345 00023000- bgh
45678 00005670 juh
34567 00002345 kij
23456 00076540- oij
34567 00007654- tgr
45678 34560000 bvf
12345 00004300- poi
45678 00054654- asd
45678 00980000- ugf
output file:
23456 -755.40 oij
12345 -273.00 poi
34567 -53.09 tgr
45678 3,35,310.16 ugf
the field 17-19 of input file is also there as the last field of output file.
but that field is taken from the last record of the corresponding account number.
for example-for the account number 45678 the last occurence of that account number in the input file record is as following
45678 00980000- ugf
therefore the field 17-19 of this record is written to the output file. similarly for all other account numbers, the last occurence of the corresponding account number's field 17-19 is taken to be written to the output file. |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Christy,
Use the following DFSORT JCL which will give you the desired results
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5----+--
23456 00001000 ADF
12345 00023000-BGH
45678 00005670 JUH
34567 00002345 KIJ
23456 00076540-OIJ
34567 00007654-TGR
45678 34560000 BVF
12345 00004300-POI
45678 00054654-ASD
45678 00980000-UGF
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=(1,5,CH,A),EQUALS
OUTFIL REMOVECC,NODETAIL,BUILD=(80X),
SECTIONS=(1,5,
TRAILER3=(1,6,
TOT=(7,9,SFF,EDIT=(SI,II,III.TT),SIGNS(,-)),
X,16,4))
//* |
The output from this job is
Code: |
12345 -273.00 POI
23456 -755.40 OIJ
34567 -53.09 TGR
45678 3,35,310.16 UGF
|
|
|