View previous topic :: View next topic
|
Author |
Message |
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi,
I have the input file as below.
Code: |
HEADER
SBR_AT 0010
DMT_AT 0010
MEM_GR 0010 GRPID20
SBR_AT 0011
DMT_AT 0011
MEM_GR 0011 GRPID10
|
The above input file must be sorted such that if (5:6) = 'GR' then it is to be sorted on groupid(13:7) and the block ordering must not change as shown below.
Code: |
HEADER
SBR_AT 0011
DMT_AT 0011
MEM_GR 0011 GRPID10
SBR_AT 0010
DMT_AT 0010
MEM_GR 0010 GRPID20
|
Is there any way to achieve this in sort?
Thanks,
Senthil |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Is all your data of that "pattern"? (if not, show a better sample input file which is representative of possible combinations, including maximum number of records per group).
What is the RECFM and LRECL of your input? |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Bill,
Yes, All the data will be present in the above pattern.
Thanks,
Senthil |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
But groupid(13:7) GRPID10, GRPID20 mentioned above will be system generated unique alphanumeric ids. For easier identification i have mentioned as GRPID |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Bill,
Sorry to mention file details, RECFM will be FB and LRECL = 626
Thanks,
Senthil |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
OK. First see if you have DATASORT available under SYNCTOOL (perhaps done as EXEC PGM=ICETOOL). That will keep the file header where it is.
Then identify your first two record types, separately, with IFTHEN=(WHEN=GROUP PUSH the entire record to separate (for each record type) extended areas on the record.
Your third record will now contain the data belonging to all three records, and it has the sort key you want. Sort on that key.
Two tasks for OUFIL. OMIT= for the original first two record types. BUILD with the "slash operator (/)" to cause multiple records to be output from one input record.
Like BUILD=(627,626,/,1253,626,/,1,626).
Then you should be about there. |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Bill,
THats great!!. I have ICETOOL option. but it would be better if u can provide me syntax as I am new to ICETOOL. Thanks.
Thanks,
Senthil |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
DATASORT is very easy. Search the forum/web and you should find some examples. You then put the processing in the USING(xxxx) file, so you have xxxxCNTL as a DD. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Senthil,
Do you always have 3 records in a 'group' assuming a group ends with some non-blank 7 byte value at pos-13? Or can it be more or less than 3?
Quote: |
if (5:6) = 'GR' then it is to be sorted on groupid(13:7) |
Does this mean that you can have groups such that the last record in the group has some value at pos-5 other than 'GR'? |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Hi Arun,
The record count can be more or less than 3 but always the last record will hold 'GR' for 1 set with non blank 7 byte from position 13.
Senthil |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Senthil,
Do you know the maximum number of records that can come in a single 'group'? |
|
Back to top |
|
|
SENTHIL MURUGAAN Warnings : 1 New User
Joined: 12 Jan 2013 Posts: 32 Location: India
|
|
|
|
Arun,
The maximum no of records for a single group cannot be predicted. As far i see the test file it holds not more than 5 records for 1 set.
But (8:4) will be always same as shown above for 1 set and will be in ascending order. This is the only position which denotes they belong to 1 group(Ex:0010,0011). If there is any way to copy this at the end for all the records for that particular group, then it helps easy sorting |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Quote: |
Is all your data of that "pattern"? (if not, show a better sample input file which is representative of possible combinations, including maximum number of records per group). |
Quote: |
Yes, All the data will be present in the above pattern. |
Quote: |
Do you always have 3 records in a 'group' assuming a group ends with some non-blank 7 byte value at pos-13? Or can it be more or less than 3? |
Quote: |
The record count can be more or less than 3... |
Quote: |
Do you know the maximum number of records that can come in a single 'group'? |
Quote: |
The maximum no of records for a single group cannot be predicted. As far i see the test file it holds not more than 5 records for 1 set. |
I'm glad that all got clarified :-) |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Senthil,
You might want to try the below Syncsort.
Note that the same input file needs to be assigned to both SORTJNF1 and SORTJNF2 DDs.
Code: |
//STEP01 EXEC PGM=SORT
//*
//SORTJNF1 DD DISP=SHR,DSN= Input file (FB/626)
//SORTJNF2 DD DISP=SHR,DSN= Input file (FB/626)
//*
//SYSOUT DD SYSOUT=*
//SORTOUT DD DSN= Output file (FB/626)
//*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(8,4,A),SORTED
JOINKEYS FILE=F2,FIELDS=(8,4,A),SORTED,
INCLUDE=(5,2,CH,EQ,C'GR')
JOIN UNPAIRED,F1
REFORMAT FIELDS=(F1:1,626,F2:13,7)
SORT FIELDS=(627,7,CH,A),EQUALS
OUTREC BUILD=(1,626)
//* |
|
|
Back to top |
|
|
|