murmohk1
Senior Member
Joined: 29 Jun 2006 Posts: 1436 Location: Bangalore,India
|
|
|
|
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 |
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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)
/*
|
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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. |
|