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
 

 

Help required on sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Help required on sort
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Sun Nov 15, 2015 11:22 am    Post subject:
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,
https://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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Mon Nov 16, 2015 8:03 pm    Post subject: Reply to: Help required on sort
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

Moderator


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

PostPosted: Tue Nov 17, 2015 12:07 am    Post subject:
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: 331
Location: USA

PostPosted: Tue Nov 17, 2015 12:53 am    Post subject: Reply to: Help required on sort
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    Post subject: Reply to: Help required on sort
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: 1238
Location: Richfield, MN, USA

PostPosted: Tue Nov 17, 2015 7:43 pm    Post subject:
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Wed Nov 18, 2015 1:55 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Nov 18, 2015 2:38 am    Post subject: Reply to: Help required on sort
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Wed Nov 18, 2015 2:50 am    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Nov 18, 2015 5:38 am    Post subject: Reply to: Help required on sort
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

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Wed Nov 18, 2015 6:02 am    Post subject:
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    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