How to get the last but one duplicate record of the file
using Sort?

Answers were Sorted based on User's Feedback



How to get the last but one duplicate record of the file using Sort?..

Answer / vikas pujar

Sort Dataset SORTXSUM will hold the duplicate records if in
Sysin dd *, we give option XSUM, after SUM FIELDS=NONE. So
last but one record in dataset should be the answer.

Is This Answer Correct ?    4 Yes 2 No

How to get the last but one duplicate record of the file using Sort?..

Answer / anju

//step1 exec pgm=sort
//sortin dd dsn=file1,disp=shr
//sortout dd dsn=file2,disp=(new,catlg,delete),
// unit=disk,space=(cyl(20,10),rlse)
// dcb=(recfm=fb,lrecl=80,blksize=800)
//sortxsum dd dsn=file3,disp=(new,catlg,delete),
// unit=disk,space=(cyl(20,10),rlse)
// dcb=(recfm=fb,lrecl=80,blksize=800)
//sysin dd *
sortfields=none,xsum
/*
//step2 exec pgm=sort
//sortin dd dsn=*.step1.sortxsum
//sortof01 dd dsn=file4,disp=(new,catlg,delete),
// unit=disk,space=(cyl(20,10),rlse)
// dcb=(recfm=fb,lrecl=80,blksize=800)
//sortof02 dd dsn=file5,disp=(new,catlg,delete),
// unit=disk,space=(cyl(20,10),rlse)
// dcb=(recfm=fb,lrecl=80,blksize=800)
sysin dd *
sortfields=copy
outfil files=01,startrec=2,endrec=2
outfil files=02,startrec=3,ENDREC=5
/*


I did not test this. Hope this will work and file4 will give
the last but 1 duplicate record.

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More JCL Interview Questions

What is the difference between a PDS member and a GDG Generation ? Is it only this, that with a generation we can use +1, 0, -1 etc while with PDS member we can not ?

7 Answers   IBM,


diff bw vsam and normal flat file?

2 Answers   CGI,


what is DSN parameter and DISP parameter is used for?

0 Answers  


If job is submitted with typerun = hold then how can we submit the same job?

3 Answers   Wipro,


what is the difference between JES3 and JES2?

0 Answers  






How to concatenate different LRECL of files?

2 Answers   IBM,


I have a File that has duplicate records. I need only those records that occur more than thrice.

3 Answers  


How to send data from cobol program to jcl?

2 Answers   CSC,


What are steplib and joblib?

0 Answers  


What are some jcl statements that are not allowed in procedures?

0 Answers  


What is the differentiation between TRK,cyl, and Bytes... how they can be connected??

2 Answers  


How dummy is used in jcl?

0 Answers  


Categories