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 

Need help to optimize the SORT card

 
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: Thu Feb 17, 2011 8:54 am    Post subject: Need help to optimize the SORT card Reply with quote

Hi,

File is 850 bytes long

I need to populate Sequence Id ( Pos 352 to 360 ) based on some field Values ( explained below) and seq id is a numeric field and its sorted based on

Acct-Id 4th position 36 length
Tran-Id 164th position 36 length

File 1 : Header ( pos 1 - 2 = '01' )
File 2. If 829-830th position is 'D2', Seq Id should be '000000010'
File 3. If 829-830th position is 'I0 and 3rd position is 'C', Seq Id should be '000000020'
File 4. If 829-830th position is 'U1', Seq Id should be '000000030'
File 5. If 829-830th position is 'I0' and 3rd position is 'D' and 248 - 251 = 'ITFR' OR 'ETFR' , Seq Id should be '000000050'
File 6. If 829-830th position is 'I0' and 3rd position is 'D' and 248 - 251 = other than 'ITFR' OR 'ETFR' , Seq Id should be '000000040'
File 7 : Trailer ( pos 1 - 2 = '03' )

This is achieved by below SORT
Code:

//SYSIN     DD *                                       
  SORT FIELDS=(4,36,CH,A,164,36,CH,A)                 
  OUTFIL FILES=01,INCLUDE=(1,2,CH,EQ,C'01')           
  OUTFIL FILES=02,                                     
  INCLUDE=(829,2,CH,EQ,C'D2'),                         
        OUTREC=(1:1,351,352:C'010000000',361:361,490) 
  OUTFIL FILES=03,                                     
  INCLUDE=(829,2,CH,EQ,C'I0',AND,3,1,CH,EQ,C'C'),     
        OUTREC=(1:1,351,352:C'020000000',361:361,490) 
  OUTFIL FILES=04,                                     
  INCLUDE=(829,2,CH,EQ,C'U1'),                         
        OUTREC=(1:1,351,352:C'030000000',361:361,490) 
  OUTFIL FILES=05,                                     
  INCLUDE=((829,2,CH,EQ,C'I0',AND,3,1,CH,EQ,C'D'),     
           AND,(248,4,CH,NE,C'ITFR',AND,               
                248,4,CH,NE,C'ETFR')),                 
        OUTREC=(1:1,351,352:C'040000000',361:361,490) 
  OUTFIL FILES=06,                                     
  INCLUDE=((829,2,CH,EQ,C'I0',AND,3,1,CH,EQ,C'D'),     
           AND,(248,4,CH,EQ,C'ITFR',OR,                 
                248,4,CH,EQ,C'ETFR')),                 
        OUTREC=(1:1,351,352:C'050000000',361:361,490)   
  OUTFIL FILES=07,INCLUDE=(1,2,CH,EQ,C'03')             
/*                                                     


Now I need to feed Seq Id 20, 40, 50 (File 3, 5, 6) as a single file to a program but sorted in Acct-Id and Tran-Id. If I concatenate since the files are split it will not be in Sorted order.

So can above Sort be made better so that condition for File 3,5,6 is met with correct Seq Id population but in a single file?





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: Thu Feb 17, 2011 11:47 am    Post subject: Reply with quote

arvibala,

Why are you splitting the files ? You can use IFTHEN statements on INREC to build the data and you can perform the sort later. Is your intention to modify the records and then sort keeping the header and trailer in place?
_________________
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: Fri Feb 18, 2011 12:59 am    Post subject: Reply with quote

Files 2-6 are detailed records and I need to populate the sequence number on detailed records based on condition described above. I need to use only the detailed records to be processed in a program which has 3 inputs. File 2 is one input, File 4 is one input and Files 3, 5, 6 combined is one input and I have to sort again files 3, 5, 6. Can this be done in one single sort?
_________________
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: Fri Feb 18, 2011 12:06 pm    Post subject: Reply with quote

arvibala wrote:
Files 2-6 are detailed records and I need to populate the sequence number on detailed records based on condition described above. I need to use only the detailed records to be processed in a program which has 3 inputs. File 2 is one input, File 4 is one input and Files 3, 5, 6 combined is one input and I have to sort again files 3, 5, 6. Can this be done in one single sort?


Arvibala,

Sort on what? A new key or same key as the original?

Just updating the values without splitting can be done as follows. You can use INREC if you want to sort on the newly added constants at pos 352.

I am just showing the updating of records based on your conditions. I added a include condition to filter unwanted records to be sorted.

Code:

//SYSIN    DD *                                                         
  INCLUDE COND=(001,2,SS,EQ,C'01,03',OR,                               
                829,2,SS,EQ,C'D2,U1',OR,                               
               (829,2,SS,EQ,C'I0',AND,3,1,SS,EQ,C'C,D'))               
                                                                       
  INREC IFTHEN=(WHEN=(829,2,CH,EQ,C'D2'),OVERLAY=(352:C'010000000')),   
  IFTHEN=(WHEN=(829,2,CH,EQ,C'U1'),OVERLAY=(352:C'030000000')),         
  IFTHEN=(WHEN=(829,2,CH,EQ,C'I0',AND,3,1,CH,EQ,C'C'),                 
       OVERLAY=(352:C'020000000')),                                     
  IFTHEN=(WHEN=(829,2,CH,EQ,C'I0',AND,3,1,CH,EQ,C'D'),                 
       OVERLAY=(352:C'040000000'),HIT=NEXT),                           
  IFTHEN=(WHEN=(829,2,CH,EQ,C'I0',AND,3,1,CH,EQ,C'D',AND,               
                248,4,SS,EQ,C'ITFR,ETFR'),OVERLAY=(352:C'050000000'))   
                                                                       
  SORT FIELDS=(4,36,CH,A,164,36,CH,A),EQUALS                           
//*

_________________
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: Fri Feb 18, 2011 1:27 pm    Post subject: Reply with quote

Thanks Kolusu,

Quote:

Sort on what? A new key or same key as the original?


I meant Sort in Same Key

I want Files 01, 02, 04, 07 as seperate files, as I have. Only 03, 05, 06 condition needs to be combined into a single file as that is related to 'I0'. Can this be done ?

Reason is one of the programs 3 inputs will be File 02, 04 and (03, 05, 06)

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: Fri Feb 18, 2011 1:55 pm    Post subject: Reply with quote

arvibala,


Use FNAMES and give meaningful names to the output files.

H1 = header file
D2 = D2 record file
...

F356 will have all the records which are not included in any of the above outfiles.

Code:

//H1       DD SYSOUT=*     
//D2       DD SYSOUT=*     
//U1       DD SYSOUT=*     
//T1       DD SYSOUT=*     
//F356     DD SYSOUT=*     


Just add OUTFIL statements to the existing sort cards I gave after sort statement.
Code:

  OUTFIL FNAMES=H1,INCLUDE=(001,2,CH,EQ,C'01')   
  OUTFIL FNAMES=D2,INCLUDE=(829,2,CH,EQ,C'D2')   
  OUTFIL FNAMES=U1,INCLUDE=(829,2,CH,EQ,C'U1')   
  OUTFIL FNAMES=T1,INCLUDE=(001,2,CH,EQ,C'03')   
  OUTFIL FNAMES=F356,SAVE                         
//*     

_________________
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: Tue Feb 22, 2011 2:01 am    Post subject: Reply with quote

Yep .... this is exactly what I was expecting ... great. Thanks a lot
_________________
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