Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Sort groups seperately based on different keys

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
Author Message
vinodkrs

New User


Joined: 25 Mar 2008
Posts: 10
Location: india

PostPosted: Tue Mar 25, 2008 6:18 pm    Post subject: Sort groups seperately based on different keys
Reply with quote

I have a input file with a mix of records which falls into 5 major groups based on a particular field. I need to sort each group seperately based on different keys. how can i do this?

SAMPLE INPUT
B Y 100
A H 150
D G 120
B K 50
C G 120
A H 125
D Y 175
A G 125
C K 145
C Y 175


OUTPUT REQ

C G 120
C K 145
C Y 175
B K 50
B Y 100
A G 125
A H 125
A H 150
D G 120
D Y 175

The output must be grouped based on some keys. in the example its the first field. there are 4 groups and i need in the order C,B,A,D. i am using dfsort
Back to top
View user's profile Send private message
References
PostPosted: Tue Mar 25, 2008 6:18 pm    Post subject: Re: Sort groups seperately based on different keys Reply with quote

guptae

Moderator


Joined: 14 Oct 2005
Posts: 989
Location: Bangalore,India

PostPosted: Tue Mar 25, 2008 6:58 pm    Post subject:
Reply with quote

Hi Vinod,

You can use following sort card for these specific group & order

Code:
INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:C'4')),             
        IFTHEN=(WHEN=(1,1,CH,EQ,C'C'),OVERLAY=(81:C'1')),
        IFTHEN=(WHEN=(1,1,CH,EQ,C'B'),OVERLAY=(81:C'2')),
        IFTHEN=(WHEN=(1,1,CH,EQ,C'A'),OVERLAY=(81:C'3')) 
  SORT FIELDS=(81,1,CH,A)                                 
** REMOVE 81ST BYTE                                       
  OUTREC BUILD=(1,80)   


Frank can give you more optimum solution.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 4190
Location: San Jose, CA

PostPosted: Tue Mar 25, 2008 9:09 pm    Post subject:
Reply with quote

Vinod,

Here's a DFSORT job that will do what you asked for:

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
B Y 100
A H 150
D G 120
B K  50
C G 120
A H 125
D Y 175
A G 125
C K 145
C Y 175
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
* Switch A and C so order for sorting is C,B,A,D.
  ALTSEQ CODE=(C3C1,C1C3)
* Specify AQ for first field so ALTSEQ table is used.
  SORT FIELDS=(1,1,AQ,A,3,1,CH,A,5,3,ZD,A)
/*
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1