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

Last record to get from a ps through JCL sort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
amiya_mf

New User


Joined: 01 Mar 2005
Posts: 18

PostPosted: Wed Mar 11, 2009 2:05 pm
Reply with quote

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
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Wed Mar 11, 2009 2:31 pm
Reply with quote

Can you please let us know how the file looks like?

Ascending or descending or not in sort order?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Wed Mar 11, 2009 2:35 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Mar 11, 2009 2:39 pm
Reply with quote

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
View user's profile Send private message
Sachinrethin

New User


Joined: 12 Oct 2007
Posts: 21
Location: Chennai

PostPosted: Wed Mar 11, 2009 2:40 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Wed Mar 11, 2009 2:43 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Mar 11, 2009 9:01 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Wed Mar 11, 2009 9:26 pm
Reply with quote

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
View user's profile Send private message
sumitmalik29
Warnings : 1

New User


Joined: 10 Feb 2008
Posts: 19
Location: bhuneswar

PostPosted: Fri Nov 27, 2009 4:05 pm
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Mon Nov 30, 2009 3:08 am
Reply with quote

Hi,

have you tried changing the 1,80 ?


Gerry
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Mon Nov 30, 2009 3:15 am
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Mon Nov 30, 2009 4:45 am
Reply with quote

Hi Dick,

Quote:
FYI :My system is not supporting SUBSET function
icon_lol.gif


Gerry
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Mon Nov 30, 2009 7:31 am
Reply with quote

Hi Gerry,

Good catch - Thanks - i missed that. . . icon_redface.gif

d
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts JCL sort to compare dates in two file... DFSORT/ICETOOL 2
No new posts Is this possible via sort (in one pass)? SYNCSORT 4
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts GDG generation name to GDG Base name ... DFSORT/ICETOOL 3
Search our Forums:

Back to Top