Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
K.Abhishek

New User

Joined: 21 Sep 2013
Posts: 2
Location: India

Posted: Sat Sep 21, 2013 1:07 am    Post subject: Sorting selectively

Hi,

I am trying to sort a file based on below mentioned fields, file length = 145
 Code: SORT FIELDS=(81,1,CH)
( default ascending)

Column 81 data is mentioned below for 10 RECORDS
 Code: A C Z H Y M Y D B H

The output gives me the sorted data as based on column 81
 Code: A B C D H H M Y Y Z

I need to get the output like
 Code: A B C D H Y Y H M Z

Sorted for all except dumps 'H' and 'Y' as they come exactly from the first instance of eithers' occurrence
is there a way to elegantly use sort to get this in a simple way .

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Sat Sep 21, 2013 1:56 am    Post subject: Reply to: Sorting selectively I assume that whichever of H or Y comes first, all the H and Y are to be sotred at that position? Elegant? You mean code that is easy to understand?
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

Posted: Sat Sep 21, 2013 3:38 am    Post subject: Reply to: Sorting selectively

OK, tested with your one-byte keys as the entire record:

 Code: * ENSURE THAT INPUT ORDER IS PRESERVED FOR DUPLICATE KEYS *   OPTION EQUALS                                                                       * OUTPUT RECORD LENGTH FROM IFTHEN PROCESSING TO BE 2 *   INREC IFOUTLEN=2,                                                                       * TREAT H,Y AS THE START OF A ONE-RECORD GROUP - TO KNOW THE * FIRST OF THE H,Y WHEN ID=01 *         IFTHEN=(WHEN=GROUP,BEGIN=(1,1,SS,EQ,C'H,Y'),                 PUSH=(2:1,1,ID=2),RECORDS=1),                                                                       * A SECOND GROUP, TO PLACE THE SORT-KEY OF THE ID=01 ON ALL SUBSEQUENT * RECORDS AS AN "OUTSORT" *         IFTHEN=(WHEN=GROUP,                 BEGIN=(3,2,CH,EQ,C'01'),                 PUSH=(2:2,1)),                                                                       * FOR THOSE WHICH ARE NOT H,Y, OVERWRITE THE OUTSORT FIELD TO GET * THE NORMAL ORDER FOR THOSE RECORDS *         IFTHEN=(WHEN=(1,1,SS,NE,C'H,Y'),                 OVERLAY=(2:1,1))   SORT FIELDS=(2,1,CH,A)                                                                       * CUT THE OUTSORT KEY OFF THE RECORD (THIS WOULD BE 1,1, BUT IS * 1,2 TO SHOW THE OUTSORT KEY) *   OUTREC BUILD=(1,2)

Output for:
 Code: A C Z H Y M Y D B H

Is:
 Code: AA BB CC DD HH YH YH HH MM ZZ

For:
 Code: A C Z Y H M Y D B H

Is:
 Code: AA BB CC DD MM YY HY YY HY ZZ
agkshirsagar

Active Member

Joined: 27 Feb 2007
Posts: 691
Location: Earth

Posted: Sat Sep 21, 2013 6:17 am    Post subject:

I am not sure if I understood the question correctly but please check if this will work -
 Code: OPTION EQUALS SORT FIELDS=(81,1,AQ,A)  ALTSEQ CODE=(C8E8)

I will test this when I get a chance on Monday.
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Sat Sep 21, 2013 1:22 pm    Post subject: Reply to: Sorting selectively "'H' and 'Y' as they come exactly from the first instance of eithers' occurrence" If the answer to my previous question is different, the AQ would do it.
K.Abhishek

New User

Joined: 21 Sep 2013
Posts: 2
Location: India

Posted: Sat Sep 21, 2013 4:36 pm    Post subject: Reply to Selective Sorting

Bill

Thanks, will come back on the process mentioned by you by Tuesday

I assume that whichever of H or Y comes first, all the H and Y are to be sorted at that position?
[Abhishek] -- Actually if you see the results shown below you would understand how it was required .
Elegant? You mean code that is easy to understand?
[Abhishek] -- I meant simple and small , not involving too many functions

agkshirsagar :Thankyou , I am sharing the results

Sort card used
 Code: OPTION EQUALS          SORT FIELDS=(1,1,AQ,A)  ALTSEQ CODE=(C8E8)

results

Input
 Code: A 00000100 C 00000200 Z 00000300 H 00000400 Y 00000500 M 00000600 Y 00000700 D 00000800 B 00000900 H 00001000

Output
 Code: A 00000100 B 00000900 C 00000200 D 00000800 M 00000600 H 00000400 Y 00000500 Y 00000700 H 00001000 Z 00000300

changed ALTSEQ CODE=(C8E8) to (E8C8) got the result I wanted
Output
 Code: A 00000100 B 00000900 C 00000200 D 00000800 H 00000400 Y 00000500 Y 00000700 H 00001000 M 00000600 Z 00000300
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7314

 Posted: Sat Sep 21, 2013 4:55 pm    Post subject: Reply to: Sorting selectively Well, happy if you are. Please describe your requirements better if there is a next time. So Y is always to be sorted as H. Although we can't see that from your results. Even the "outsort" becomes ludicrously simple, but the ALTSEQ is more elegant. agkshirsagar, good intuition.
agkshirsagar

Active Member

Joined: 27 Feb 2007
Posts: 691
Location: Earth

 Posted: Mon Sep 23, 2013 8:25 pm    Post subject: Thanks, Bill. Abhishek, Glad to know it helped.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Sorting on text - but in non-alphabet... Roy Ware SYNCSORT 5 Wed Aug 23, 2017 9:15 pm Sorting of hex values Saurabh_mi DFSORT/ICETOOL 11 Thu May 25, 2017 3:49 pm Sorting group data rajella DFSORT/ICETOOL 4 Sun Jan 22, 2017 11:32 pm Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am Stripping and Sorting of VB file G SRINIVASA RAO SYNCSORT 5 Wed Sep 14, 2016 1:34 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us