Trying to sort the details records within this kind of report does not make sense. I'd suggest getting just the detail records from the report, sorting them, and then redoing the report with the header records. Or better yet, go back to the original program that created the report and have it sort the detail records by salary.
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
This can be done using ICETOOL. Look at the following code:
//SORTIN EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=XXXX.XXXX.XXXX,DISP=SHR
//*** MUST USE DISP=MOD FOR OUTPUT - MAKE SURE
//*** THE OUTPUT DATA SET IS EMPTY INITIALLY
//OUT DD DISP=MOD,DSN=YYYY.YYYY.YYYY(0),
//TOOLIN DD *
* COPY HEADER RECORD
COPY FROM(IN) TO(OUT) USING(HHHH)
* SORT DETAIL RECORDS
SORT FROM(IN) TO(OUT) USING(DDDD)
* COPY TRAILER RECORD
COPY FROM(IN) TO(OUT) USING(TTTT)
//HHHHCNTL DD *
* GET HEADER RECORD (FIRST)
//DDDDCNTL DD *
* SKIP HEADER RECORD
* SKIP TRAILER RECORD
** USE AN OMIT CONDITION THAT DISTINGUISHES
** IDENTIFY THE TRAILER RECORD FROM THE DETAIL RECORDS WITH A **KEY FIELD
* SORT ALL BUT THE HEADER AND TRAILER RECORDS
//TTTTCNTL DD *
* SKIP HEADER RECORD
* GET TRAILER RECORD
** USE AN INCLUDE CONDITION THAT DISTINGUISHES
** THE TRAILER RECORD FROM THE DETAIL RECORDS
** (SAME AS ABOVE)
The above code sorts detail records leaving both Header and Footer. I have give elobrate comments to each parameters. Look at them and tune this code according for your requirement. Let me know if you face any difficulty.
I don't think you actually understand the complexity of the requirement.
I believe your job would only work for one page of the report (if that) and is less efficient for doing that then the "Sort records between a header and trailer" Smart DFSORT Trick which does that in one pass.
Go back and look at Narisimha's original post again and you'll see that the report has multiple pages and each page has a header that has to be kept for that page, and detail records which have to be sorted by salary. And the detail records may not even end up on their original pages. For example, a salary from page 3 could be the lowest salary and end up on page 1.
Do you really think the job you show handles all that?
You'd still have to move each sorted-by-salary detail record to the correct page. You can't just extract a page, sort the detail records on that page and put it back. You have to sort all of the detail records on every page and put them back on the correct pages. For example, the current last record on the last page may be the first record when sorted by salary and thus would have to be moved to the first page. It really makes more sense to extract the data records, sort them and then recreate the report with the headers.
You are correct Frank.I think the only way out is to extract the detail records get them sorted and re create the report or else sort the input file by salary and feed to the program which creates the report(if salary is not calculated in the report program)