View previous topic :: View next topic
|
Author |
Message |
kalakuntlavenkat
New User
Joined: 10 Nov 2008 Posts: 6 Location: Hyderabad
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Is it not possible to correct input? |
|
Back to top |
|
|
RahulG31
Active User
Joined: 20 Dec 2014 Posts: 446 Location: USA
|
|
|
|
@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 |
|
|
kalakuntlavenkat
New User
Joined: 10 Nov 2008 Posts: 6 Location: Hyderabad
|
|
|
|
Hi Bill, Thanks for your response. I will try and come back to you. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
Bill, One question, Does SORT FIELDS affects the working of ( KEYBEGIN and PUSH)? |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3048 Location: NYC,USA
|
|
|
|
Very true, thanks again. |
|
Back to top |
|
|
|