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

Sum a field Value for a condition


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Mon Apr 28, 2008 9:39 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts S0C7 - Field getting overlayed COBOL Programming 2
No new posts Masking variable size field - min 10 ... DFSORT/ICETOOL 4
Search our Forums:

Back to Top