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

Keeping fields on a summarization record


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
speermb

New User


Joined: 27 Aug 2008
Posts: 30
Location: USA

PostPosted: Mon Jul 09, 2012 6:37 pm
Reply with quote

I have a file that I am summing 2 fields and need to keep specific data from field 3, when field 3 is equal to "2". The sum always happens based on key, but if there is 1 record on that key with field3="2" I need to keep the "2" in field3. The only way I can think of is to sum file into 1 file, save all "2" into another file then splice the 2 back together. Is there another way?

Currently, I have code:
Code:
  SORT FIELDS=(01,04,CH,A,               
               05,04,CH,A,               
               09,01,CH,A,               
               10,01,CH,A,               
               11,09,CH,A,               
               20,05,CH,A,               
               25,10,CH,A)               
 OUTREC FIELDS=(1,44,                     
               52,52,                     
               +0,TO=PD,LENGTH=9,         
               +0,TO=PD,LENGTH=9,         
               104,9,                     
               113,9,                     
               122,4,                     
               C'C',                     
               175X)                     
    SUM FIELDS=(104,9,PD,                 
                113,9,PD)                 


Input: (the wanted field is the 2 in the "2C" area)
Code:

00462012RC16H45206 436S92012-02-212012-02-21JBSTCV ..LAS VEGAS SANDS CORP                              .................ýN 1C..
00462012RC16H45206 436S92012-02-212012-02-21JBSTCV ..LAS VEGAS SANDS CORP                              ......°........ìã.N 2C..
00462012RC16H45206 436S92012-02-212012-02-21JBSTCV ..LAS VEGAS SANDS CORP                              ..............ì&`)N 2C..


Output:
Code:
00462012RC16H45206 436S92012-02-212012-02-21..LAS VEGAS SANDS CORP                              ................................Ñ.&(N 1CC


Wanted Output:
Code:
00462012RC16H45206 436S92012-02-212012-02-21..LAS VEGAS SANDS CORP                              ................................Ñ.&(N 2CC
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Jul 09, 2012 8:45 pm
Reply with quote

Your problem is that the first record into the SUM is used as the base for the summing. If you have EQUALS, you will always get the first record on the input file as the base, without EQUALS you will get whatever record happens along first.

You want the last record, it looks like.

What is the order of the input file? Are you only doing the SORT to allow the SUM?
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts To Discard record with 0 entry if Dup... SYNCSORT 7
No new posts To Populate Trailer cnt in the file w... SYNCSORT 1
No new posts Write record twice based on condition... SYNCSORT 7
No new posts Create a specific record/file based o... SYNCSORT 8
No new posts Sort to insert record in an empty file. DFSORT/ICETOOL 5
Search our Forums:


Back to Top