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

sort var2 in ESDS without changing var1 positions


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

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Mon Dec 04, 2006 4:21 pm
Reply with quote

Hi,

I have a ESDS like this -

VAR1 VAR2
----------------
005 a
005 b
001 b
001 a

004 a
004 b
002 a
002 b

VAR1 has duplicate records. whereas VAR2 has unique value for the corresponding VAR1. Also note that VAR1 is stored in random order.

Now my requirement is to sort var2 without effecting the var1 positions (like internal sorting for VAR1 records). I had highlighted records in RED above which needs to be sorted.


Resultant file should look like -

VAR1 VAR2
----------------
005 a
005 b
001 a
001 b

004 a
004 b
002 a
002 b



Regards & Thanks,
Mohan
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Dec 04, 2006 4:26 pm
Reply with quote

Sort on var2 while telling sort to keep the original sequence for equals.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Mon Dec 04, 2006 10:32 pm
Reply with quote

Mohan,

Here's a DFSORT job that will do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but you can change the job appropriately for other attributes.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
005     a
005     b
001     b
001     a
004     a
004     b
002     a
002     b
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,
                   97:SEQNUM,8,ZD,RESTART=(1,3))),
        IFTHEN=(WHEN=(97,8,ZD,EQ,+1),
                OVERLAY=(81:SEQNUM,8,ZD)),
        IFTHEN=(WHEN=NONE,
                OVERLAY=(89:SEQNUM,8,ZD,
                         81:81,8,ZD,SUB,89,8,ZD,M11,LENGTH=8))
  SORT FIELDS=(81,8,ZD,A,9,1,CH,A)
  OUTREC BUILD=(1,80)
/*
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Mon Dec 04, 2006 10:34 pm
Reply with quote

Quote:
Sort on var2 while telling sort to keep the original sequence for equals.


William,

This is NOT a solution to the stated problem (I'm not even sure what you mean by this). Please test your "solutions" to make sure they are valid before posting them to avoid confusing people.
Back to top
View user's profile Send private message
murmohk1

Senior Member


Joined: 29 Jun 2006
Posts: 1436
Location: Bangalore,India

PostPosted: Tue Dec 05, 2006 8:07 am
Reply with quote

Thanks for the quick solution, Frank.
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 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 Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts Random read in ESDS file by using RBA JCL & VSAM 6
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top