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

Dynamic sort where the keys are not on the same positition


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cima

New User


Joined: 22 Mar 2006
Posts: 8

PostPosted: Tue Jun 15, 2010 12:10 pm
Reply with quote

Hi all,

I'd like to know if its possible to sort a file, where the keys are not always on the same position.

example:

Input:
ID001.................ID002................ID003..10....................
ID001.................ID003..07..............ID004......................
ID001.................ID003..02..............ID004......................
ID001.................ID002................ID003..01....................

Output:
ID001.................ID002................ID003..01....................
ID001.................ID003..02..............ID004......................
ID001.................ID003..07..............ID004......................
ID001.................ID002................ID003..10....................

Problem: In ID003, there is a subkey (two-digit) which I'd like to sort. However, ID003's position is variable because not all IDs are always present, like the 2nd record, where ID002 is omitted.

Is sorting in this case possible?

Thanks,
cima
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 15, 2010 9:46 pm
Reply with quote

cima,

Assuming your input is FB recfm and LRECL of 80 , use the following DFSORT JCL which will give you the desired results

Code:

//STEP0100 EXEC PGM=SORT                                           
//SYSOUT   DD SYSOUT=*                                             
//SORTIN   DD *                                                   
ID001.................ID002................ID003..10...............
ID001.................ID003..07............ID004...................
ID001.................ID003..02............ID004...................
ID001.................ID002................ID003..01...............
//SORTOUT  DD SYSOUT=*                                             
//SYSIN    DD *                                                   
  INREC PARSE=(%00=(STARTAFT=C'ID003..',FIXLEN=2)),BUILD=(1,80,%00)
  SORT FIELDS=(1,5,CH,A,81,2,CH,A)                                 
  OUTREC BUILD=(1,80)                                             
//*
Back to top
View user's profile Send private message
cima

New User


Joined: 22 Mar 2006
Posts: 8

PostPosted: Mon Jun 21, 2010 10:26 am
Reply with quote

Hi Skolusu,

Thanks for the reply..

Actually its VB and LRECL 29998.. Also the 2 DOTS between ID003 and the 2digit Subkey are just fillers.. They have values like:

ID003AB02abcdefg1234ID004
ID003CD07asdfjkl12341ID004

The bluemarked text can have different values..

Sorry for the incomplete infos..

Thanks,
cima
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue Jun 22, 2010 3:29 am
Reply with quote

cima wrote:
Hi Skolusu,

Thanks for the reply..

Actually its VB and LRECL 29998.. Also the 2 DOTS between ID003 and the 2digit Subkey are just fillers.. They have values like:

Sorry for the incomplete infos..

Thanks,
cima


Cima,

It would save a lot of time , if you are clear with your requirements. Anyway use the following control cards which will give you the desired results.

Code:

//SYSIN    DD *                                                   
  INREC PARSE=(%00=(STARTAFT=C'ID003',FIXLEN=4)),BUILD=(1,4,%00,5)
  SORT FIELDS=(9,5,CH,A,7,2,CH,A),EQUALS                         
  OUTREC BUILD=(1,4,9)                                           
//*
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Alternative of JoinKeys in SORT DFSORT/ICETOOL 2
No new posts DFSORT Join Keys Controlcard DFSORT/ICETOOL 4
No new posts Sort SMF records? SYNCSORT 6
No new posts To Sort detail records in a file with... SYNCSORT 5
No new posts Any way to prevent dynamic allocation? DFSORT/ICETOOL 6
Search our Forums:


Back to Top