Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Last record to get from a ps through JCL sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
amiya_mf

New User


Joined: 01 Mar 2005
Posts: 19

PostPosted: Wed Mar 11, 2009 2:05 pm    Post subject: Last record to get from a ps through JCL sort
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    Post subject:
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: 1703
Location: Australia

PostPosted: Wed Mar 11, 2009 2:35 pm    Post subject:
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: 2276
Location: @my desk

PostPosted: Wed Mar 11, 2009 2:39 pm    Post subject:
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    Post subject: Re:Last record to get from a ps through JCL sort
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: 2276
Location: @my desk

PostPosted: Wed Mar 11, 2009 2:43 pm    Post subject:
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

Site Director


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

PostPosted: Wed Mar 11, 2009 9:01 pm    Post subject:
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 Moderator


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

PostPosted: Wed Mar 11, 2009 9:26 pm    Post subject:
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    Post subject:
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: 1703
Location: Australia

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

Hi,

have you tried changing the 1,80 ?


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

Site Director


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

PostPosted: Mon Nov 30, 2009 3:15 am    Post subject:
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: 1703
Location: Australia

PostPosted: Mon Nov 30, 2009 4:45 am    Post subject:
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

Site Director


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

PostPosted: Mon Nov 30, 2009 7:31 am    Post subject: Reply to: Last record to get from a ps through JCL sort
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am
No new posts SORT JSON type of data maxsubrat DFSORT/ICETOOL 8 Wed Apr 19, 2017 6:01 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us