Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to sort only detail records ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: How to sort only detail records ?
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 Moderator


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

PostPosted: Tue Apr 10, 2007 9:23 pm    Post subject:
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    Post subject: Re: How to sort only detail records ?
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 Moderator


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

PostPosted: Tue Apr 10, 2007 11:00 pm    Post subject:
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    Post subject: Re: How to sort only detail records ?
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    Post subject: Re: How to sort only detail records ?
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 Moderator


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

PostPosted: Wed Apr 11, 2007 8:54 pm    Post subject:
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    Post subject: Re: How to sort only detail records ?
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Check if any Detail records and extra... V S Amarendra Reddy SYNCSORT 19 Mon May 08, 2017 8:54 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us