u can try with 2 steps. first SORT step should create a temp dataset in descending order and the second SORT step should have STOPAFT=10
in the control statement. Thus you will get last 10 records.
Guys let me know if there are any other options.
If it is in ascending order then what you told was correct. He has not mentioned about whether input dataset is sorted in ascending order or not.
I think it should be by other means.
Guys please suggest is there any other options ?
Joined: 26 Apr 2004 Posts: 4650 Location: Raleigh, NC, USA
This example assumes that the dataset is FB, LRECL=80.
//COPY EXEC PGM=ICETOOL
//IN DD DISP=SHR,DSN=input
//T1 DD DSN=&&T1,DISP=(,PASS),UNIT=VIO
//OUT DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) USING(CTL2)
//CTL1CNTL DD *
* ADD SEQUENCE NUMBERS TO RECORDS, THEN SORT BY SEQUENCE
* NUMBER IN DESCENDING ORDER, SELECTING ONLY THE LAST 10
//CTL2CNTL DD *
* SORT THE RECORDS BACK INTO THEIR ORIGINAL ORDER, AND
* REMOVE THE SEQUENCE NUMBERS.