MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort only detailed records.

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Tue Feb 22, 2011 2:32 am    Post subject: Sort only detailed records. Reply with quote

Hi,

My file has 3 type of records.

Header starts with '01', detailed starts with '02' and Trailer starts with '03'. Since multiple source sends the files, one of our process has multiple header and multiple trailer as input.

But, I want to sort only detailed records based on Acct Id ( 4th pos 36 length ).

The header and trailer records should not be sorted and remain as it is. Right now I split these into 3 files and sort only detailed records and then concatenate. But I am expecting solution in a single SORT step.

I saw this from ICETOOL

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN1 DD DSN=... input file
//OUT1 DD DSN=... output file
//TOOLIN DD *
DATASORT FROM(IN1) TO(OUT1) HEADER(2) TRAILER(3) USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(4,36,CH,A)
/*

But this work only if we know the number of headers and trailers that will come in a file.

Help pls

Sample Input
Code:

01header03
01header05
01header03
01header02
02C0000012
02C0000010
02C0000022
02C0000002
02C0000011
02C0000001
02C0000008
02C0000006
02C0000004
03Trailer02
03Trailer01
03Trailer03


Expected Output
Code:

01header03
01header05
01header03
01header02
02C0000001
02C0000002
02C0000004
02C0000006
02C0000008
02C0000010
02C0000011
02C0000012
02C0000022
03Trailer02
03Trailer01
03Trailer03


Thanks
_________________
Arvind
"You can make a difference with your smile. Have that with you always"
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Tue Feb 22, 2011 11:19 am    Post subject: Reply with quote

arvibala,

Assuming the LRECL is 80 and RECFM FB, the following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                             
//SYSOUT   DD SYSOUT=*                               
//SORTIN   DD *                                       
01HEADER03                                           
01HEADER05                                           
01HEADER03                                           
01HEADER02                                           
02C0000012                                           
02C0000010                                           
02C0000022                                           
02C0000002                                           
02C0000011                                           
02C0000001                                           
02C0000008                                           
02C0000006                                           
02C0000004                                           
03TRAILER02                                           
03TRAILER01                                           
03TRAILER03                                           
//SORTOUT  DD SYSOUT=*                               
//SYSIN    DD *                                       
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:1,2,4,36)),     
  IFTHEN=(WHEN=(1,2,SS,EQ,C'01,03'),OVERLAY=(83:36X))
  SORT FIELDS=(81,38,CH,A),EQUALS                     
  OUTREC BUILD=(1,80)                                 
//*

_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
arvibala
Beginner


Joined: 12 Feb 2008
Posts: 142
Topics: 67

PostPosted: Wed Feb 23, 2011 6:00 am    Post subject: Reply with quote

Thank You
_________________
Arvind
"You can make a difference with your smile. Have that with you always"
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group