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 a group of record types without sequence change

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Sorting a group of record types without sequence change
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: 1506
Location: Chennai

PostPosted: Wed May 25, 2011 12:31 pm    Post subject:
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    Post subject: Re: Sorting a group of record types without sequence change
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: 1506
Location: Chennai

PostPosted: Wed May 25, 2011 2:38 pm    Post subject:
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    Post subject:
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    Post subject:
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 Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed May 25, 2011 10:44 pm    Post subject:
Reply with quote

Nihal,

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

http://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    Post subject:
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    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 Read two inputs and write into output... murali.andaluri DFSORT/ICETOOL 6 Wed Jul 26, 2017 7:35 pm
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am


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