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

Sorting and summing within detail record multiple headers


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

New User


Joined: 24 Feb 2006
Posts: 18
Location: Chennai

PostPosted: Thu Mar 21, 2013 7:13 pm
Reply with quote

Hi All,

I have the following requirement and i tried to find a solution searching old posts in the forum but couldn't find one.

The requirement is i have a sequential file fixed length 40 bytes.
The file has multiple header records and under each header, multiple detail records. The output file should have header records as-is and detail records sorted on field2 and field3 should be summed up using field 2 as key. (After summing, the field4 in detail can be from any record of the key, there is no restriction)

Header record:
Field1: 1 byte, always have value 1 to say header.
Field2: 4 bytes, any value
Field3: 35 bytes any value

Detail record:
Field1: 1 byte, always have value 2 to say detail
Field2: 4byte, any value
Field3: 3 byte, any 3 digit number
field4: 32 byte any value

Sample data
10004headerrecord1
20001003AAA
20001002BBB
20002004CCC
20002003DDD
20002002EEE
20003001FFF
20003004GGG
10002headerrecord2
20001003AAA
20001004BBB
20002001CCC
20002003DDD
20002002EEE
20003005FFF
20003002GGG
10001headerrecord3
20001003AAA
20001004BBB


The Expected output is

10004headerrecord1
20001005AAA
20002009CCC
20003005FFF
10002headerrecord2
20001007AAA
20002006CCC
20003007FFF
10001headerrecord3
20001007AAA


Many thanks in advance.
Back to top
View user's profile Send private message
saiprasadh

Active User


Joined: 20 Sep 2006
Posts: 154
Location: US

PostPosted: Thu Mar 21, 2013 7:47 pm
Reply with quote

Parthasarathy,


Please use below mentioned sort card.

Code:
 SORT FIELDS=(41,5,ZD,A,1,1,ZD,A,2,4,ZD,A)                   
 INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,ZD,EQ,1),               
       PUSH=(41:ID=5))                                       
 SUM FIELDS=(6,3,ZD)       
 OUTREC FIELDS=(1,40)
   



Output:

Code:
10004HEADERRECORD1             
20001005AAA                   
20002009CCC                   
20003005FFF                   
10002HEADERRECORD2             
20001007AAA                   
20002006CCC                   
20003007FFF                   
10001HEADERRECORD3             
20001007AAA                 
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: Fri Mar 22, 2013 5:46 am
Reply with quote

You'll have to make your mind up about Field 4. Does it matter (OPTION EQUALS, if you want the first record of a group of duplitcates to be the base)? Or not?
Back to top
View user's profile Send private message
Parthasarathy

New User


Joined: 24 Feb 2006
Posts: 18
Location: Chennai

PostPosted: Fri Mar 22, 2013 2:37 pm
Reply with quote

Thanks a ton for the solution icon_biggrin.gif
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
Search our Forums:

Back to Top