Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 To remove spaces from a VB file using... Selvarajars DFSORT/ICETOOL 2 Thu Jun 21, 2018 6:57 pm
This topic is locked: you cannot edit posts or make replies. To remove spaces in a variable length... Selvarajars JCL & VSAM 1 Thu Jun 21, 2018 1:07 pm
No new posts Sort numeric fields with trailing spaces sancraig16 SYNCSORT 7 Tue Apr 03, 2018 1:21 am
No new posts Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am
No new posts SORT 3 files,extract specific fields ... Kiransr DFSORT/ICETOOL 13 Fri Mar 23, 2018 10:54 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us