Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sum the amount of the same acount

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sum the amount of the same acount
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Amount field is getting corrupted whe... thesumitk SYNCSORT 5 Tue Oct 18, 2016 8:20 pm
No new posts TSO Logon Failing - Acount Not matching SLNewton TSO/ISPF 1 Thu Aug 25, 2016 9:37 pm
No new posts How can amount of the Storage Usage b... esduman61 CICS 6 Wed Mar 09, 2016 1:19 pm
No new posts Get rows based on amount entered from... Rohit Umarjikar DB2 10 Thu Feb 25, 2016 9:57 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us