Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

sort var2 in ESDS without changing var1 positions

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
murmohk1

Senior Member


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

PostPosted: Mon Dec 04, 2006 4:21 pm    Post subject: sort var2 in ESDS without changing var1 positions
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: 3158
Location: Tucson AZ

PostPosted: Mon Dec 04, 2006 4:26 pm    Post subject:
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 Moderator


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

PostPosted: Mon Dec 04, 2006 10:32 pm    Post subject:
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 Moderator


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

PostPosted: Mon Dec 04, 2006 10:34 pm    Post subject:
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: 1439
Location: Bangalore,India

PostPosted: Tue Dec 05, 2006 8:07 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm
No new posts abend sort based on count records in ... anatol DFSORT/ICETOOL 5 Mon Oct 17, 2016 10:10 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us