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

SYNCSORT file with duplicates as well as with unique records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abhay pratap singh

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Tue Dec 11, 2007 9:02 pm
Reply with quote

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
View user's profile Send private message
abhay pratap singh

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Tue Dec 11, 2007 9:18 pm
Reply with quote

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
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 496
Location: USA

PostPosted: Wed Dec 12, 2007 1:03 am
Reply with quote

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
View user's profile Send private message
abhay pratap singh

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Wed Dec 12, 2007 10:59 am
Reply with quote

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
View user's profile Send private message
ameenansari

New User


Joined: 18 Sep 2006
Posts: 11
Location: chennai

PostPosted: Wed Dec 12, 2007 1:17 pm
Reply with quote

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
View user's profile Send private message
abhay pratap singh

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Wed Dec 12, 2007 4:24 pm
Reply with quote

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
View user's profile Send private message
krisprems

Active Member


Joined: 27 Nov 2006
Posts: 649
Location: India

PostPosted: Wed Dec 12, 2007 4:56 pm
Reply with quote

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
View user's profile Send private message
ameenansari

New User


Joined: 18 Sep 2006
Posts: 11
Location: chennai

PostPosted: Wed Dec 12, 2007 5:29 pm
Reply with quote

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
View user's profile Send private message
raak

Active User


Joined: 23 May 2006
Posts: 166
Location: chennai

PostPosted: Thu Dec 13, 2007 10:00 am
Reply with quote

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

New User


Joined: 18 Sep 2006
Posts: 11
Location: chennai

PostPosted: Thu Dec 13, 2007 1:08 pm
Reply with quote

Ya. i got it. thanks raak
Back to top
View user's profile Send private message
abhay pratap singh

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Thu Dec 13, 2007 1:40 pm
Reply with quote

Thanks to all for responding, solution provided by krisprem ithru icetool is working.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top