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 SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts outrec field outside range Danielle.Filteau SYNCSORT 10 Sat Mar 04, 2017 2:37 am
No new posts Joinkeys with condition scdinesh DFSORT/ICETOOL 10 Tue Feb 14, 2017 12:20 am
No new posts 2 byte YEAR from Y'DATE2' field tecnokrat DFSORT/ICETOOL 2 Tue Feb 07, 2017 12:05 pm


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