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

Sort to get Max value from file on one column


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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: 1208
Location: Bangalore,India

PostPosted: Wed Feb 21, 2007 5:05 pm
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 Developer


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

PostPosted: Wed Feb 21, 2007 10:14 pm
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: 1208
Location: Bangalore,India

PostPosted: Thu Feb 22, 2007 10:08 am
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 Developer


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

PostPosted: Thu Feb 22, 2007 9:19 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Replacing 'YYMMDD' with date, varying... SYNCSORT 3
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top