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
 

 

Sorting selectively

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

New User


Joined: 21 Sep 2013
Posts: 2
Location: India

PostPosted: Sat Sep 21, 2013 1:07 am    Post subject: Sorting selectively
Reply with quote

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 .
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat Sep 21, 2013 1:56 am    Post subject: Reply to: Sorting selectively
Reply with quote

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?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat Sep 21, 2013 3:38 am    Post subject: Reply to: Sorting selectively
Reply with quote

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
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Sat Sep 21, 2013 6:17 am    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat Sep 21, 2013 1:22 pm    Post subject: Reply to: Sorting selectively
Reply with quote

"'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.
Back to top
View user's profile Send private message
K.Abhishek

New User


Joined: 21 Sep 2013
Posts: 2
Location: India

PostPosted: Sat Sep 21, 2013 4:36 pm    Post subject: Reply to Selective Sorting
Reply with quote

Bill

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

As for your queries ,
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
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Sat Sep 21, 2013 4:55 pm    Post subject: Reply to: Sorting selectively
Reply with quote

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.
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Mon Sep 23, 2013 8:25 pm    Post subject:
Reply with quote

Thanks, Bill.

Abhishek, Glad to know it helped.
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 Efficient sorting chandracdac DFSORT/ICETOOL 5 Sat Oct 22, 2016 3:23 am
No new posts Stripping and Sorting of VB file G SRINIVASA RAO SYNCSORT 5 Wed Sep 14, 2016 1:34 pm
No new posts DFSORT sorting only specific records akodakka DFSORT/ICETOOL 4 Thu Aug 04, 2016 11:24 am
No new posts VB file sorting V S Amarendra Reddy DFSORT/ICETOOL 2 Fri Feb 26, 2016 8:29 pm
No new posts File sorting and summing up values at... kenshin DFSORT/ICETOOL 3 Wed Sep 23, 2015 2:14 am


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