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

how to pull MAX value record


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

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Jul 04, 2012 3:32 pm
Reply with quote

Hi,

My input file (LRECL=80, RECFM=FB) has several records among which I want to pick records with MAX value present in it.

Input:
Code:

RECORDA01840
RECORDA01842
RECORDA01846
HOSANNA00001
HOSANNA00005
HOSANNA00006
HOSANNA00008


Expected Output:
Code:

RECORDA01846
HOSANNA00008


How to achieve it? Please help.

Thanks.
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Wed Jul 04, 2012 3:40 pm
Reply with quote

This link might be useful.

ibmmainframes.com/viewtopic.php?t=48595
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jul 04, 2012 3:55 pm
Reply with quote

Do you need the output as in the same order of input file??
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Wed Jul 04, 2012 3:58 pm
Reply with quote

Please try and let us know the results.

Code:
//TOOLIN   DD *                                                 
  SELECT FROM(IN1) TO(OUT) ON(1,7,CH) FIRST USING(CTL1)         
//CTL1CNTL DD *                                                 
 SORT FIELDS=(8,5,ZD,D)                                         
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Jul 04, 2012 4:09 pm
Reply with quote

wow.....thanks. icon_biggrin.gif
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jul 04, 2012 4:11 pm
Reply with quote

Gnana Sekaran Nallathambi,

This control card wont work properly

for input like this

Code:

RECORDA01840
RECORDA01842
RECORDA01846
HOSANNA90001
HOSANNA00005
HOSANNA00006
HOSANNA90008
Back to top
View user's profile Send private message
Gnanas N

Active Member


Joined: 06 Sep 2007
Posts: 792
Location: Chennai, India

PostPosted: Wed Jul 04, 2012 4:17 pm
Reply with quote

Okay, Prem.

If ramsri confirms that is also a possible case and the desired output, please post SORT cards for the same.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Wed Jul 04, 2012 4:25 pm
Reply with quote

Hi Ramsri,

This should help you if you need to retain the order

Code:

//OUTPUT    DD  DSN=&C2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//OUTPUT2 DD SYSOUT=*
//TOOLIN   DD *
  SELECT FROM(INPUT) TO(OUTPUT) ON(1,7,CH) FIRST USING(CTL1)
  COPY   FROM(OUTPUT) TO(OUTPUT2) USING(CTL2)
//CTL1CNTL DD *
  INREC OVERLAY=(81:SEQNUM,8,ZD)
  SORT FIELDS=(1,7,CH,A,8,5,ZD,D)
//CTL2CNTL DD *
  SORT FIELDS=(81,8,ZD,A)
  OUTREC FIELDS=(1:1,80)


Hi Gnana,

You need to make use of feven 1,7 in your CTL1 so that the key doesnt get split into different sets and also the below code doesnt have the same order of input

Code:
//TOOLIN   DD *                                                 
  SELECT FROM(IN1) TO(OUT) ON(1,7,CH) FIRST USING(CTL1)         
//CTL1CNTL DD *                                                 
 SORT FIELDS=(1,7,CH,A,8,5,ZD,D)   
Back to top
View user's profile Send private message
vasanthz

Global Moderator


Joined: 28 Aug 2007
Posts: 1742
Location: Tirupur, India

PostPosted: Wed Jul 04, 2012 4:31 pm
Reply with quote

Hi Gnana,
Your solution is nice. But I think this
Quote:
//TOOLIN DD *
SELECT FROM(IN1) TO(OUT) ON(1,7,CH) FIRST USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=(8,5,ZD,D)

needs to be changed to
Code:
//TOOLIN   DD *                                                 
  SELECT FROM(IN1) TO(OUT) ON(1,7,CH) FIRST USING(CTL1)         
//CTL1CNTL DD *                                                 
    SORT FIELDS=(1,7,CH,A,8,5,CH,D) 
/*


Edited :S did not see previous post. contention
Back to top
View user's profile Send private message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Wed Jul 04, 2012 7:00 pm
Reply with quote

thanks for all the responses.
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 SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Validating record count of a file is ... DFSORT/ICETOOL 13
Search our Forums:

Back to Top