IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Help required on sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
kalakuntlavenkat

New User


Joined: 10 Nov 2008
Posts: 6
Location: Hyderabad

PostPosted: Sun Nov 15, 2015 8:55 am
Reply with quote

Hi Friends,

I have one requirement like, I have one file with 26 byte length. There are records with from byte 1 to 18 data is same and 19 26 is date value and it is in not sort order.

My requirement is , from 1 to 18 bytes data should be at same in the file (no of records before sort and after sort should be at same position in the file)and 19 to 26 data should be sorted.

expamle -

Code:
VIEW       BST.BS0007.ZSORTS10.BS0701.D291015T             Columns 00001 00026
 Command ===>                                                  Scroll ===> CSR
 =COLS> ----+----1----+----2----+-
 006901 GRBQS2Q2012081321320150901
 006902 GR9CZDV2013020921320150909   ----
 006903 GR9CZDV2013020921320150910  -----
 006904 GR9CZDV2013020921320150909  ------
 006905 GRB2BS82013052621320150914
 006906 GRBQS2Q2013081321320150901
 006907 GR988XD2014040521320150910
 006908 GR988XD2014040521320150909
 006909 GRB2BS82014052621320150914
 006910 GRBQS2Q2014081321320150902
 006911 GRBQS2Q2014081321320150903
 006912 GR98K8X2014100821320150923
 006913 GRBPRBG2013031721320150902
 006914 GRBPRVR2015010821320150902
 006915 GRBPRVR2015010821320150903
 006916 GRBPRVR2015010821320150904
 006917 GR9F0N62015082521320150909
 006918 GR9F0N62015082521320150910


if you take for example record no 6902, 6903 and 6904 after sort it should be like below

Code:
VIEW       BST.BS0007.ZSORTS10.BS0701.D291015T             Columns 00001 00026
 Command ===>                                                  Scroll ===> CSR
 =COLS> ----+----1----+----2----+-
 006901 GRBQS2Q2012081321320150901
]006902 GR9CZDV2013020921320150910  ---
 006903 GR9CZDV2013020921320150909  ---
 006904 GR9CZDV2013020921320150909  -----
 006905 GRB2BS82013052621320150914
 006906 GRBQS2Q2013081321320150901
 006907 GR988XD2014040521320150910
 006908 GR988XD2014040521320150909
 006909 GRB2BS82014052621320150914
 006910 GRBQS2Q2014081321320150902
 006911 GRBQS2Q2014081321320150903
 006912 GR98K8X2014100821320150923
 006913 GRBPRBG2013031721320150902
 006914 GRBPRVR2015010821320150902
 006915 GRBPRVR2015010821320150903
 006916 GRBPRVR2015010821320150904
 006917 GR9F0N62015082521320150909
 006918 GR9F0N62015082521320150910


Could you please help me here
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Sun Nov 15, 2015 11:22 am
Reply with quote

Why do you want to do this? it will mess up the whole record as you are trying to exchange the value of the record.
Still you want to do it then check the similar method,
www-01.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.icea100/ice2ca_Example_14._Sort_with_IFTHEN.htm
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Nov 16, 2015 8:03 pm
Reply with quote

You need INREC with IFTHEN=(WHEN=GROUP for your key and PUSH an ID to a temporary extension to the record.

SORT on the ID then the date (descending, it looks like from your sample output). Then strip off the temporary ID with OUTREC or OUTFIL. Specify EQUALs by your site's chosen method, if you need to preserve the input order of the original file in relation to the SORT.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Nov 17, 2015 12:07 am
Reply with quote

Is it not possible to correct input?
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Nov 17, 2015 12:53 am
Reply with quote

@Pandora-Box: I believe the input is generated through a program.
And, changing a program requires more effort, time and testing (and a potential to introduce new bugs).
But if such a sort step is added to existing job then it should be minimal effort and it will be easier to pin point the problem if the results are not as required or if the changes need to be reverted.

*just my thoughts
Back to top
View user's profile Send private message
kalakuntlavenkat

New User


Joined: 10 Nov 2008
Posts: 6
Location: Hyderabad

PostPosted: Tue Nov 17, 2015 7:23 pm
Reply with quote

Hi Bill, Thanks for your response. I will try and come back to you.
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Tue Nov 17, 2015 7:43 pm
Reply with quote

Quote:
And, changing a program requires more effort, time and testing (and a potential to introduce new bugs).

It's usually better in the long run to correct the data at the source instead of correcting it downstream.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Nov 18, 2015 1:55 am
Reply with quote

Bill, One question, Does SORT FIELDS affects the working of ( KEYBEGIN and PUSH)?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 18, 2015 2:38 am
Reply with quote

Rohit, I don't understand the question. INREC and SORT are logically separate things, there is no direct interaction between them. If you are asking can SORT affect the results of INREC processing, the answer is No.

Here, the data is in primary key order (which is simply the physical order of the keys) and the secondary key has to be sequenced within the primary. Since that requires a SORT, something needs to be done to keep the original records in the original key order, even though the key is not in "collating sequence" order. So you make a key which is in collating sequence and mirrors the order of the keys on the input. Then you can SORT on that to keep the records where they were, apart from the low-order SORT to get them into the required date order within the key.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Nov 18, 2015 2:50 am
Reply with quote

Thanks Bill. I may have missed the understanding here for sure.
Here is what I am doing.
Code:
----+----1----+----2----+----3----+----4----+----5----+----6
//SORTIN   DD *                                             
A A 1                                                       
A A 3                                                       
B B 2                                                       
B B 6                                                       
B B 2                                                       
//SORTOUT  DD SYSOUT=*                                     
//SYSIN    DD *                                             
  OUTREC IFTHEN=(WHEN=GROUP,KEYBEGIN=(1,3),PUSH=(6:ID=1))   
  SORT FIELDS=(6,1,CH,A,5,1,CH,D)                           
  OUTFIL BUILD=(1,6)                                       
//* 

I expect below output ( that is what TS wants )
Code:
A A 3                                                       
A A 1                                                       
B B 6                                                       
B B 2                                                       
B B 2   

I am getting below output( I kept last byte as ID as well just to see what values present)
Code:
B B 61
A A 32
B B 23
B B 23
A A 14

And if I remove the SORT FIELDS it gives me below,
Code:
A A 11
A A 31
B B 22
B B 62
B B 22


Ohhh I realized my mistake , I used OUTREC instead of INREC. Please excuse me.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Nov 18, 2015 5:38 am
Reply with quote

Remember, it doesn't matter where you physically locate different SORT Control Statements, they will always be processed exactly where SORT processes them. If you code OUTREC before SORT, your SORT will be processed first, then the OUTREC.

If you stick to only using OUTREC when you need its properties (it runs after SORT, and if you want to do something with the data once it is SORTed, use OUTREC (or OUTFIL)) then you'll get less confusion like this.
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

PostPosted: Wed Nov 18, 2015 6:02 am
Reply with quote

Very true, thanks again.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
No new posts how to calculate SUM for VB file usin... JCL & VSAM 1
No new posts leading spaces can be removed in trai... DFSORT/ICETOOL 1
Search our Forums:

Back to Top