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
 

 

Sort to get Max value from file on one column

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
shivani_jha

New User


Joined: 12 Feb 2007
Posts: 11
Location: mumbai

PostPosted: Wed Feb 21, 2007 4:51 pm    Post subject: Sort to get Max value from file on one column
Reply with quote

I have a sequential file LREC=80.

abc 2007-02-21-00.00.00.000000 ddd ddd
abc 2007-02-20-00.00.00.000001 ddd ddd
abc 2007-01-21-00.00.00.000010 ddd ddd
abc 2007-02-05-00.00.00.000009 ddd ddd
abc 2007-02-05-00.00.00.000009 ddd ddd
abc 2006-02-21-00.00.00.000000 ddd ddd
abc 2007-01-01-00.00.00.000000 ddd ddd

I have to fetch the Max value of time stamp field from all records using SORT.

How can I find the MAX value of field from postion 4 length 26 bytes and write the max value to a new file using sort.
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Wed Feb 21, 2007 5:05 pm    Post subject:
Reply with quote

Hi There,

You can use following sort card
Code:

//SYSIN    DD  *                             
   SORT FIELDS=(4,26,CH,D)                   
   OUTFIL FILES=1,ENDREC=1,OUTREC=(4,26,80:X)
/* 
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 Feb 21, 2007 10:14 pm    Post subject:
Reply with quote

Shivani,

4,26 doesn't correspond to the input records you show. Either you meant 5,26 or the timestamp starts in position 4, not 5. At any rate, here's a more efficient way to do what you want with DFSORT then Ekta showed, since it uses a copy rather than a sort.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
abc2007-02-21-00.00.00.000000 ddd ddd
abc2007-02-20-00.00.00.000001 ddd ddd
abc2007-01-21-00.00.00.000010 ddd ddd
abc2007-02-05-00.00.00.000009 ddd ddd
abc2007-02-05-00.00.00.000009 ddd ddd
abc2006-02-21-00.00.00.000000 ddd ddd
abc2007-01-01-00.00.00.000000 ddd ddd
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
    TRAILER1=(MAX=(4,26,UFF,
     EDIT=(TTTT-TT-TT-TT.TT.TT.TTTTTT)))
/*
Back to top
View user's profile Send private message
guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Thu Feb 22, 2007 10:08 am    Post subject:
Reply with quote

HI Frank,

Thanks for optimizing it.

Does my method give a solution correctly?
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: Thu Feb 22, 2007 9:19 pm    Post subject:
Reply with quote

Quote:
Does my method give a solution correctly?


Yes.
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am


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