IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Sum the amount of the same acount


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Christy

New User


Joined: 17 Nov 2010
Posts: 14
Location: India

PostPosted: Wed Feb 02, 2011 3:13 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Wed Feb 02, 2011 10:25 pm
Reply with quote

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
Back to top
View user's profile Send private message
Christy

New User


Joined: 17 Nov 2010
Posts: 14
Location: India

PostPosted: Thu Feb 03, 2011 9:48 am
Reply with quote

Thank you very much.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Amount of days between two dates PL/I & Assembler 8
No new posts Adding a trailer with record count an... JCL & VSAM 4
No new posts Identify the value if the SUM of the ... SYNCSORT 4
No new posts Formating of Amount field in CLIST be... CLIST & REXX 9
No new posts how to add the amount for duplicate r... COBOL Programming 9
Search our Forums:

Back to Top