IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need suggestion in sort


IBM Mainframe Forums -> SYNCSORT
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
SENTHIL MURUGAAN
Warnings : 1

New User


Joined: 12 Jan 2013
Posts: 32
Location: India

PostPosted: Wed Jul 24, 2013 12:00 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 24, 2013 12:06 pm
Reply with 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).

What is the RECFM and LRECL of your input?
Back to top
View user's profile Send private message
SENTHIL MURUGAAN
Warnings : 1

New User


Joined: 12 Jan 2013
Posts: 32
Location: India

PostPosted: Wed Jul 24, 2013 12:11 pm
Reply with quote

Hi Bill,

Yes, All the data will be present in the above pattern.

Thanks,
Senthil
Back to top
View user's profile Send private message
SENTHIL MURUGAAN
Warnings : 1

New User


Joined: 12 Jan 2013
Posts: 32
Location: India

PostPosted: Wed Jul 24, 2013 12:13 pm
Reply with quote

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
View user's profile Send private message
SENTHIL MURUGAAN
Warnings : 1

New User


Joined: 12 Jan 2013
Posts: 32
Location: India

PostPosted: Wed Jul 24, 2013 12:24 pm
Reply with quote

Hi Bill,
Sorry to mention file details, RECFM will be FB and LRECL = 626

Thanks,
Senthil
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 24, 2013 12:43 pm
Reply with quote

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
View user's profile Send private message
SENTHIL MURUGAAN
Warnings : 1

New User


Joined: 12 Jan 2013
Posts: 32
Location: India

PostPosted: Wed Jul 24, 2013 1:03 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 24, 2013 1:23 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Jul 24, 2013 2:10 pm
Reply with quote

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
View user's profile Send private message
SENTHIL MURUGAAN
Warnings : 1

New User


Joined: 12 Jan 2013
Posts: 32
Location: India

PostPosted: Wed Jul 24, 2013 2:23 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Jul 24, 2013 3:22 pm
Reply with quote

Senthil,

Do you know the maximum number of records that can come in a single 'group'?
Back to top
View user's profile Send private message
SENTHIL MURUGAAN
Warnings : 1

New User


Joined: 12 Jan 2013
Posts: 32
Location: India

PostPosted: Wed Jul 24, 2013 3:30 pm
Reply with quote

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
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Jul 24, 2013 9:59 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Thu Jul 25, 2013 2:39 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> SYNCSORT

 


Similar Topics
Topic Forum Replies
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
No new posts FB to .CSV conversion using sort DFSORT/ICETOOL 7
Search our Forums:

Back to Top