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
 

 

Sorting and summing within detail record multiple headers

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sorting and summing within detail record multiple headers
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7254

PostPosted: Fri Mar 22, 2013 5:46 am    Post subject: Reply to: Sorting and summing within detail record multiple
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    Post subject: Reply to: Sorting and summing within detail record multiple
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    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 Summing on Mixed Case Literals Roy Ware SYNCSORT 3 Tue Jan 03, 2017 10:18 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm
No new posts Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am
No new posts sort with previous record anatol DFSORT/ICETOOL 9 Thu Oct 06, 2016 2:36 am
No new posts Get Record count in summary record fo... Atul Banke DFSORT/ICETOOL 21 Fri Sep 23, 2016 4:17 pm


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