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

Sorting a group of record types without sequence change


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

New User


Joined: 07 Nov 2007
Posts: 12
Location: Hyderabad

PostPosted: Wed May 25, 2011 9:32 am
Reply with quote

Hi All,

Hope everyone is doing great. This time I am stuck with an interesting requirement.

I have a file with different record types such as header, merchant header, merchant records, detail records, merchant trailer and the file trailer.

First byte = 1 (File Header)
First byte = 2 (Merchant Header)
First byte = 3 (Detail Record)
First byte = 4 (Merchant Trailer)
First byte = 9 (File trailer)

My requirement is to sort only the detail records and keep all the other records in place.

Sorting of detail records is on the key starting from 2nd position to 4 bytes.

Sampe Input file:
1HEADER1
2MERCHANT HEADER1
3REC5
3REC1
3REC4
3REC3
3REC2
4MERCHANT TRAILER1
9FILE TRAILER1
1HEADER2
2MERCHANT HEADER2
3REC3
3REC5
3REC4
3REC1
3REC2
4MERCHANG TRAILER2
9FILE TRAILER2
1HEADER3
2MERCHANT HEADER3
3REC3
3REC5
3REC4
3REC1
3REC2
4MERCHANG TRAILER3
9FILE TRAILER3

Desired Output file:
1HEADER1
2MERCHANT HEADER1
3REC1
3REC2
3REC3
3REC4
3REC5
4MERCHANT TRAILER1
9FILE TRAILER1
1HEADER2
2MERCHANT HEADER2
3REC1
3REC2
3REC3
3REC4
3REC5
4MERCHANG TRAILER2
9FILE TRAILER2
1HEADER3
2MERCHANT HEADER3
3REC1
3REC2
3REC3
3REC4
3REC5
4MERCHANG TRAILER3
9FILE TRAILER3

Hope I am clear with my requirement and thanks a lot in advance.

Regards,
Viswanath.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Wed May 25, 2011 12:31 pm
Reply with quote

Hello,

You could try the below job for the requirement,
Code:
//JS020    EXEC PGM=ICETOOL                       
//TOOLMSG  DD SYSOUT=*                           
//DFSMSG   DD SYSOUT=*                           
//SORTIN   DD DISP=SHR,DSN=WELLS.SORTIN         
//SORTOUT  DD DSN=WELLS.SORTOUT,DISP=OLD       
//SYSOUT   DD SYSOUT=*                           
//TOOLIN   DD *                                   
SORT FROM(SORTIN) TO(SORTOUT) USING(CTL1)       
/*                                                                                                 
//CTL1CNTL   DD *                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'1'),
   PUSH=(81:ID=8))                               
 SORT FIELDS=(81,8,ZD,A,1,1,ZD,A,2,4,CH,A)       
   OUTREC BUILD=(1,80)                           
/*                                               
//SYSUDUMP DD SYSOUT=*                           
/*                                               


Hope it helps.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Wed May 25, 2011 1:53 pm
Reply with quote

At some point in career, a sort user faces this requirement in same form or with a slight change.

The icetool way of doing it looks cool. But this can as well be done in DFSORT(with a little bit of clever logic). I did that back in 2007.

Let me know if you are interested in the other way of doing it.
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Wed May 25, 2011 2:38 pm
Reply with quote

mmm.. To do it with DFSORT

Use the same statements above in SYSIN of DFSORT,

Code:
//PS020    EXEC PGM=SORT
//SYSOUT   DD  SYSOUT=*
//SYSUDUMP DD  SYSOUT=*
//SORTIN   DD  DSN=WELLS.SORTIN,DISP=SHR
//SORTOUT  DD  DSN=WELLS.SORTOUT,DISP=OLD
//SYSIN    DD  *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,CH,EQ,C'1'),
   PUSH=(81:ID=8))                               
   SORT FIELDS=(81,8,ZD,A,1,1,ZD,A,2,4,CH,A)       
   OUTREC BUILD=(1,80)
/*


CNTL DD's in ICETOOL are like SYSIN for DFSORT.

Quote:
But this can as well be done in DFSORT(with a little bit of clever logic).I did that back in 2007.

Please share your technique as well, as it might help in learning.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Wed May 25, 2011 3:29 pm
Reply with quote

Nothing new. This is precisely the technique I was talking about(sort sequence characters in the unused columns of record). This is taken care by:
BEGIN=(1,1,CH,EQ,C'1'),
PUSH=(81:ID=8))


This is a nice and neat way of grouping same batch of records together.

Though, I did a bit differently coz I did not know about begin and push(in dfsort). I did the sequencing of records in seperate step using Selcopy. Have these commands recently been added to DFSORT?
Back to top
View user's profile Send private message
Escapa

Senior Member


Joined: 16 Feb 2007
Posts: 1399
Location: IL, USA

PostPosted: Wed May 25, 2011 5:15 pm
Reply with quote

Quote:
Have these commands recently been added to DFSORT?

In this fast it world.. I wont call July, 2008 as recently... icon_smile.gif ..
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: Wed May 25, 2011 10:44 pm
Reply with quote

Nihal,

If you want to know when specific functions were added to DFSORT or DFSORT's ICETOOL, see:

www.ibm.com/support/docview.wss?rs=114&uid=isg3T7000084
Back to top
View user's profile Send private message
vissubhai

New User


Joined: 07 Nov 2007
Posts: 12
Location: Hyderabad

PostPosted: Mon May 30, 2011 6:57 am
Reply with quote

Thanks vasanthz & nihalansari. The solution worked like charm
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 Binary File format getting change whi... All Other Mainframe Topics 7
No new posts How to split large record length file... DFSORT/ICETOOL 10
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 To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top