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

Sum total of Amount fields based on key value in same file


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mvmadhavi

New User


Joined: 09 Nov 2006
Posts: 22

PostPosted: Thu Apr 24, 2025 11:15 am
Reply with quote

Code:
I have a requirement as below

Plan   Contract   name1   name2   amt1
111    456        abc      xyz    456.00
222    456        def      pqr    678.00
333    789        ijk      rte    4567.65
            
output should be like:            
            
Plan   Contract   name1   name2   amt1
111    456        abc      xyz    456.00
222    456        def      pqr    678.00
                                 1,134.00
 
333    789        ijk      rte    4567.65





Based on same contract the amounts should be summed up and printed in the next line under amt1 field only. giving

I have seen a few posts with sum fields =(1,12,zd), this does not serve the purpose of printing the sum in next line.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1448
Location: Bamberg, Germany

PostPosted: Thu Apr 24, 2025 3:44 pm
Reply with quote

Your line 333 has no sum field, but it should have.

Code:
OUTFIL FNAMES=(SORTOUT),               
  REMOVECC,                             
  SECTIONS=(8,3,SKIP=2L,               
    TRAILER3=(19X,TOT=(35,10,UFF,M18)))


Code:
****** ***************************** Top of Data *****
000001 111    456        abc      xyz    456.00       
000002 222    456        def      pqr    678.00       
000003                                 1,134.00       
000004                                               
000005 333    789        ijk      rte    4567.65     
000006                                 4,567.65       
****** **************************** Bottom of Data ***
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2290
Location: USA

PostPosted: Thu Apr 24, 2025 5:27 pm
Reply with quote

This is one of the very first samples from ANY manual on SORT utility.

The post must go to the beginners, or students forum.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1448
Location: Bamberg, Germany

PostPosted: Thu Apr 24, 2025 10:58 pm
Reply with quote

It certainly is a candidate. icon_arrow.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3112
Location: NYC,USA

PostPosted: Fri Apr 25, 2025 6:16 am
Reply with quote

Moved thanks
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts IGYPG3178-I when compiling a pgm read... COBOL Programming 6
No new posts FileAid move data from two files to o... Compuware & Other Tools 5
No new posts Sorting date into YYYYMMDD, and creat... DFSORT/ICETOOL 13
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts To Populate Trailer cnt in the file w... SYNCSORT 1
Search our Forums:


Back to Top