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 a field Value for a condition

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Niha Rai

New User


Joined: 27 Apr 2008
Posts: 1
Location: India

PostPosted: Mon Apr 28, 2008 10:22 am    Post subject: Sum a field Value for a condition
Reply with quote

I have a file with following records:
F1 F2 F3
A 50.00 001
B 42.00 002
A 51.00 002
A 23.00 004
B 27.00 004
C 59.00 001

I want that the output should sum the field F2 when F1 is same and F3 = 002 or 004, so the output should contain

A 50.00 001
A 74.00 002
B 69.00 002
C 59.00 001

Please suggest a sort card using PGM=SORT
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Mon Apr 28, 2008 9:39 pm    Post subject:
Reply with quote

You can use a DFSORT job like this:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file (FB/11)
//SORTOUT DD DSN=...  output file (FB/11)
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(12:1,1,13:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=(9,3,SS,EQ,C'002,004'),OVERLAY=(13:8C'0'))
  SORT FIELDS=(12,9,CH,A)
  OUTFIL REMOVECC,NODETAIL,
    BUILD=(1,11),
    SECTIONS=(12,9,
      TRAILER3=(1,1,3:TOT=(3,5,UFF,EDIT=(TT.TT)),9:9,3))
/*
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 INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
This topic is locked: you cannot edit posts or make replies. How to pass the previous month date i... Suganya87 DFSORT/ICETOOL 5 Mon Oct 31, 2016 4:13 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm


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