View previous topic :: View next topic
|
Author |
Message |
abhay pratap singh
New User
Joined: 22 Nov 2007 Posts: 77 Location: noida
|
|
|
|
I have a input file(physical sequential) with records as mentioned below:
DDA8000000000000978300012111120
DDA8000000000000978300013111120
DDA4000000000000978500001120000
DDA4000000000000978500001320000
DDA8000000000000978623456789123
REA4500000000000978700123456789
REA8000000000000978800170000000
I want to sort the above file on position 5 for length 15. The output file should contain the unique records as well as the last record of duplicate ones.The output file should look like:
DDA8000000000000978300013111120
DDA4000000000000978500001320000
DDA8000000000000978623456789123
REA4500000000000978700123456789
REA8000000000000978800170000000
Sort card i used was SORT FIELDS=(5,15,ZD,A),SUM FIELDS=NONE but i didn't got the expected result.
Can i do it thru sort utility in one step. |
|
Back to top |
|
|
abhay pratap singh
New User
Joined: 22 Nov 2007 Posts: 77 Location: noida
|
|
|
|
abhay pratap singh wrote: |
I want to sort the above file on position 5 for length 15.
Sort card i used was SORT FIELDS=(5,15,ZD,A),SUM FIELDS=NONE
|
Please correct it to
I want to sort the above file on position 6 for length 15.
Sort card i used was SORT FIELDS=(6,15,ZD,A),SUM FIELDS=NONE |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
Quote: |
Can i do it thru sort utility in one step. |
Yes.
Try this:
Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
DDA8000000000000978300012111120
DDA8000000000000978300013111120
DDA4000000000000978500001120000
DDA4000000000000978500001320000
DDA8000000000000978623456789123
REA4500000000000978700123456789
REA8000000000000978800170000000
//SYSIN DD *
INREC FIELDS=(1,31,32:SEQNUM,8,ZD)
SORT FIELDS=(6,15,ZD,A,32,8,CH,A),EQUALS
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(6,15,TRAILER3=(1,31))
/*
|
|
|
Back to top |
|
|
abhay pratap singh
New User
Joined: 22 Nov 2007 Posts: 77 Location: noida
|
|
|
|
Alissa,
I think you have assumed th input file as fixed(RECFM=FB) and LRECL=80 but the file is having RECFM=VB and LRECL=2004.
Will the solution provided by you will work for VB file. |
|
Back to top |
|
|
ameenansari
New User
Joined: 18 Sep 2006 Posts: 11 Location: chennai
|
|
|
|
Hi Parathap,
This will work
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD DSN=INSC.DEC12,DISP=SHR //* I/P VB FILE
//SYSIN DD *
SORT FIELDS=(9,16,ZD,A)
SUM FIELDS=NONE
/*
Thanks
Ameen |
|
Back to top |
|
|
abhay pratap singh
New User
Joined: 22 Nov 2007 Posts: 77 Location: noida
|
|
|
|
ameenansari wrote: |
Hi Parathap,
This will work
//SYSIN DD *
SORT FIELDS=(9,16,ZD,A)
SUM FIELDS=NONE
/*
|
Ameen,
SUM FIELDS=NONE will give first record of the duplicate records and my requirement is to get last record of the duplicates.I have mentioned this in my problem. |
|
Back to top |
|
|
krisprems
Active Member
Joined: 27 Nov 2006 Posts: 649 Location: India
|
|
|
|
Code: |
//***********************************************
//GETMATCH EXEC PGM=SYNCTOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
----+----1----+----2----+----3----+----4----+----
DDA8000000000000978300012111120
DDA8000000000000978300013111120
DDA4000000000000978500001120000
DDA4000000000000978500001320000
DDA8000000000000978623456789123
REA4500000000000978700123456789
REA8000000000000978800170000000
/*
//OUT DD SYSOUT=*
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(6,15,CH) LAST
/* |
OUT:
Code: |
DDA8000000000000978300013111120
DDA4000000000000978500001320000
DDA8000000000000978623456789123
REA4500000000000978700123456789
REA8000000000000978800170000000
|
|
|
Back to top |
|
|
ameenansari
New User
Joined: 18 Sep 2006 Posts: 11 Location: chennai
|
|
|
|
Pratap,
I/P:-(INSC.DEC12)-VB OF2004 RECLENGTH
DDA8000000000000978300012111120
DDA8000000000000978300013111120
DDA4000000000000978500001120000
DDA4000000000000978500001320000
DDA8000000000000978623456789123
REA4500000000000978700123456789
REA8000000000000978800170000000
SORT JCL:
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD DSN=INSC.DEC12,DISP=SHR
//SYSIN DD *
SORT FIELDS=(10,15,ZD,A)
SUM FIELDS=NONE
/*
SORTOUT:-
DDA8000000000000978300012111120
DDA4000000000000978500001120000
DDA8000000000000978623456789123
REA4500000000000978700123456789
REA8000000000000978800170000000
I got your output with this simple sort. Is this your requirement?. Wat is the use for getting last record of duplicates. |
|
Back to top |
|
|
raak
Active User
Joined: 23 May 2006 Posts: 166 Location: chennai
|
|
|
|
Quote: |
I got your output with this simple sort. Is this your requirement?. Wat is the use for getting last record of duplicates. |
As far as the Input given by abhay is considered, it doesn't make any difference...because in the input given, he has the same value in all the columns for the duplicate records..
But the difference comes when there are different values in fields which are outside the SORT fields.. i.e. other than the (6,15) columns..
For example, consider this i/p
DDB8000000000000978300012111120
DDA8000000000000978300013111120
In this case, If we use the sort card given by u, it will return the first record. But if u use the SYNCTOOL with LAST option, it will return the last record of the duplicate..(Duplicate is determined only on the values for which u r doing the sort)..
There lies the difference!!!
I beleive i am not wrong here..Otherwise please correct me... |
|
Back to top |
|
|
ameenansari
New User
Joined: 18 Sep 2006 Posts: 11 Location: chennai
|
|
|
|
Ya. i got it. thanks raak |
|
Back to top |
|
|
abhay pratap singh
New User
Joined: 22 Nov 2007 Posts: 77 Location: noida
|
|
|
|
Thanks to all for responding, solution provided by krisprem ithru icetool is working. |
|
Back to top |
|
|
|