View previous topic :: View next topic
|
Author |
Message |
amiya_mf
New User
Joined: 01 Mar 2005 Posts: 18
|
|
|
|
Hi,
Can we get the last record from a PS? Please let me know.
EX.
i have input data as follows:
0001 AAAA BBBBB
0001 AAAA BBBBB
0002 CCCC DDDD
0002 CCCC DDDD
0003 EEEE FFFFFF
Output file should have the below record.
0003 EEEE FFFFFF
Thanks,
Amiya |
|
Back to top |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
|
|
Can you please let us know how the file looks like?
Ascending or descending or not in sort order? |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
try this
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0001 AAAA BBBBB
0001 AAAA BBBBB
0002 CCCC DDDD
0002 CCCC DDDD
0003 EEEE FFFFFF
/*
//SORTOUT DD DSN=&&C1,UNIT=SYSDA,SPACE=(TRK,(1,1)),DISP=(,PASS)
//SYSIN DD *
OPTION COPY
OUTFIL BUILD=(80:X),REMOVECC,NODETAIL,
TRAILER1=(' OPTION COPY,SKIPREC=',COUNT-1=(M11,LENGTH=8))
/*
//S2 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
0001 AAAA BBBBB
0001 AAAA BBBBB
0002 CCCC DDDD
0002 CCCC DDDD
0003 EEEE FFFFFF
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD DSN=&&C1,DISP=(OLD,PASS)
|
Gerry |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
amiya_mf,
You can easily achieve this using the below SyncSort job.
Code: |
//STEP1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SORTIN DD *
0001 AAAA BBBBB
0001 AAAA BBBBB
0002 CCCC DDDD
0002 CCCC DDDD
0003 EEEE FFFFFF
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,TRAILER1=(1,80) |
|
|
Back to top |
|
|
Sachinrethin
New User
Joined: 12 Oct 2007 Posts: 21 Location: Chennai
|
|
|
|
Hi,
Another method to crack this..
INREC OVERLAY=(81:SEQNUM,8,ZD)
SORT FIELDS=(81,8,ZD,D)
OUTFIL FILES=01,ENDREC=01,BUILD=(1,80) |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Quote: |
Another method to crack this.. |
Of course this works. But I think it's less efficient because of the additional overhead in attaching the sequence number and again sorting it in descending order. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
because of the additional overhead |
and for the sortwork dasd and cpu cycles for sorting and for the "extra" copy of the file to be written. . .
Methinks this is only an acceptable solution if your family is the hardware vendor for the organization. . .
If you only have 5 records, this might be ok, but i'd suggest most requirements have some larger volume of data. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Amiya,
Here's a DFSORT/ICETOOL job that will do what you want for any RECFM and LRECL:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=... output file
//TOOLIN DD *
SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST
/*
|
|
|
Back to top |
|
|
sumitmalik29 Warnings : 1 New User
Joined: 10 Feb 2008 Posts: 19 Location: bhuneswar
|
|
|
|
Hi
My requirement is to fetch the last record having record length = 2000. But using the below sort card getting only the 80 bytes length record.
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,TRAILER1=(1,80)
How can I get the full length record of 2000 bytes.
FYI :My system is not supporting SUBSET function |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
have you tried changing the 1,80 ?
Gerry |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Did you try the solution Frank posted just before your question?
It mentions that it will work for any recfm/lrecl. . . |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi Dick,
Quote: |
FYI :My system is not supporting SUBSET function |
Gerry |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Gerry,
Good catch - Thanks - i missed that. . .
d |
|
Back to top |
|
|
|