Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 sort records based on length exceeds ... maxsubrat DFSORT/ICETOOL 7 Wed Oct 04, 2017 4:48 pm
No new posts Execute JCL step based on the content... sprikitik JCL & VSAM 2 Tue Oct 03, 2017 10:03 am
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts JOINKEYS Paired and Unpaired Sort MFwhiz DFSORT/ICETOOL 4 Fri Sep 29, 2017 1:48 am
No new posts Garbage on output file Hervey Martinez SYNCSORT 4 Wed Sep 27, 2017 12:50 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us