Posted: Thu Feb 17, 2011 8:54 am Post subject: Need help to optimize the SORT card
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' )
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"
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Thu Feb 17, 2011 11:47 am Post subject:
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
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"
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
Posted: Fri Feb 18, 2011 12:06 pm Post subject:
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'))
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"
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"
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