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

How to sort only detail records ?


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Narismha

New User


Joined: 22 Nov 2006
Posts: 23
Location: Mumbai

PostPosted: Tue Apr 10, 2007 6:38 pm
Reply with quote

Hi,

I have file with headers and details records. I want to sort only detail record without disturbing header records( File has page break logic).

INPUT file:

Page1
Header1

Emp sal dep serv
------ ----- ----- ------
0001 2222 093 20
0003 1111 042 25
0004 3333 023 15

Page2
Header1

Emp sal dep serv
------ ----- ----- ------
0005 5555 023 30
0006 4444 022 20


REquired output:

Page1
Header1

Emp sal dep serv
------ ----- ----- ------
0003 1111 042 25
0001 2222 093 20
0004 3333 023 15

Page2
Header1

Emp sal dep serv
------ ----- ----- ------
0006 4444 022 20
0005 5555 023 30


I want a sort by Sal in the detail record.

Please let me know your suggestion.

Thanks
-Narisimha
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Apr 10, 2007 9:23 pm
Reply with quote

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

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Tue Apr 10, 2007 10:47 pm
Reply with quote

Hi Narismha,

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),
// DCB=(LRECL=080,RECFM=FB),
// SPACE=(TRK,(10,10),RLSE),
// UNIT=DISK
//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)
OPTION STOPAFT=1
/*
//DDDDCNTL DD *
* SKIP HEADER RECORD
OPTION SKIPREC=1
* SKIP TRAILER RECORD
** USE AN OMIT CONDITION THAT DISTINGUISHES
** IDENTIFY THE TRAILER RECORD FROM THE DETAIL RECORDS WITH A **KEY FIELD
OMIT COND=(1,4,CH,EQ,C'VAMS')
* SORT ALL BUT THE HEADER AND TRAILER RECORDS
SORT FIELDS=(1,6,CH,A)
/*
//TTTTCNTL DD *
* SKIP HEADER RECORD
OPTION SKIPREC=1
* GET TRAILER RECORD
** USE AN INCLUDE CONDITION THAT DISTINGUISHES
** THE TRAILER RECORD FROM THE DETAIL RECORDS
** (SAME AS ABOVE)
INCLUDE COND=(1,4,CH,EQ,C'VAMS')
/*


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.

~Vamsi
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Apr 10, 2007 11:00 pm
Reply with quote

Vamsi,

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?
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Tue Apr 10, 2007 11:05 pm
Reply with quote

Yes Frank,

You are right. I will agree with you. My code won't work for reports.

~Vamsi
Back to top
View user's profile Send private message
skkp2006

New User


Joined: 14 Jul 2006
Posts: 93
Location: Chennai,India

PostPosted: Wed Apr 11, 2007 10:26 am
Reply with quote

Can we think of splitting the file/report by pages and joining it back after sorting by salary ??? icon_rolleyes.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Wed Apr 11, 2007 8:54 pm
Reply with quote

How exactly would you do 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.
Back to top
View user's profile Send private message
skkp2006

New User


Joined: 14 Jul 2006
Posts: 93
Location: Chennai,India

PostPosted: Thu Apr 12, 2007 10:13 am
Reply with quote

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)

Thanks...
Syam
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
Search our Forums:

Back to Top