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: 1381
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: 2194
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: 1381
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: 3084
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts Write record twice based on condition... SYNCSORT 5
No new posts Sort card to know that creation date ... DFSORT/ICETOOL 9
No new posts Convert CSV to flat file. DFSORT/ICETOOL 6
No new posts Multiple INSPECTS on a big size file COBOL Programming 6
No new posts Create a specific record/file based o... SYNCSORT 8
Search our Forums:

Back to Top