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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top