View previous topic :: View next topic
|
Author |
Message |
shivani_jha
New User
Joined: 12 Feb 2007 Posts: 11 Location: mumbai
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
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 |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
HI Frank,
Thanks for optimizing it.
Does my method give a solution correctly? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Quote: |
Does my method give a solution correctly? |
Yes. |
|
Back to top |
|
|
|