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
 

 

Copy only the last record from file with Syncsort

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

New User


Joined: 18 Apr 2007
Posts: 23
Location: Chennai

PostPosted: Tue Apr 28, 2009 9:11 pm    Post subject: Copy only the last record from file with Syncsort
Reply with quote

Hi All,

I have a file which contains 'N' recs. Could you please let me know of a way to copy only the last or nth rec onto a another file?

Thanks,
Hariharan
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Tue Apr 28, 2009 9:27 pm    Post subject:
Reply with quote

This is a good place to start
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Tue Apr 28, 2009 9:30 pm    Post subject:
Reply with quote

For the last, look at Sort step to Bring the last record to Beginning.
Fro the nth, look at SKIPREC specifies the number of records z you want to skip (delete) before starting to sort or copy the input data set.
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: Tue Apr 28, 2009 10:45 pm    Post subject:
Reply with quote

Hariharan,

Here's a DFSORT job that will copy the last record:

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
/*


Here's a DFSORT job that will copy the nth record. Replace n with the record number (e.g. 3):

Code:

//S2   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 RRN(n)
/*



For complete details on the SUBSET operator of DFSORT's ICETOOL, see:

www.ibm.com/systems/support/storage/software/sort/mvs/ugpf/
Back to top
View user's profile Send private message
hariharan_82

New User


Joined: 18 Apr 2007
Posts: 23
Location: Chennai

PostPosted: Tue Apr 28, 2009 11:11 pm    Post subject:
Reply with quote

Thanks Fank!!

However I get this erre!

SYNCTOOL RELEASE 1.6.1 - COPYRIGHT 2007 SYNCSORT INC.
INITIAL PROCESSING MODE IS "STOP"
"TOOLIN" INTERFACE BEING USED

SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST
STATEMENT DOES NOT BEGIN WITH A VALID OPERATOR
OPERATION COMPLETED WITH RETURN CODE 12

PROCESSING MODE CHANGED FROM "STOP" TO "SCAN" DUE TO OPERATION FAILURE

SYNCTOOL PROCESSING COMPLETED WITH RETURN CODE 12

Woudl that mean something is not set up right wrt to the version of ICETOOL am havin?

Thanks,
Hariharan
Back to top
View user's profile Send private message
hariharan_82

New User


Joined: 18 Apr 2007
Posts: 23
Location: Chennai

PostPosted: Tue Apr 28, 2009 11:13 pm    Post subject:
Reply with quote

Sorry about the spelling icon_smile.gif keyboad is all screwed up
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: Tue Apr 28, 2009 11:14 pm    Post subject:
Reply with quote

The SYT messages indicate you're using Syncsort, not DFSORT. The job works fine with DFSORT which has supported SUBSET since July, 2008.

I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
Back to top
View user's profile Send private message
hariharan_82

New User


Joined: 18 Apr 2007
Posts: 23
Location: Chennai

PostPosted: Wed Apr 29, 2009 12:02 am    Post subject:
Reply with quote

So is there no way to do this using SYNCTOOL and SYNCSORT?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Wed Apr 29, 2009 12:16 am    Post subject:
Reply with quote

hariharan_82 wrote:
So is there no way to do this using SYNCTOOL and SYNCSORT?
Have you bothered to look at the provided links?
Back to top
View user's profile Send private message
hariharan_82

New User


Joined: 18 Apr 2007
Posts: 23
Location: Chennai

PostPosted: Wed Apr 29, 2009 12:29 am    Post subject:
Reply with quote

Yes. But I would want to do this througgh SYNCTOOL in one step.
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 Apr 29, 2009 12:39 am    Post subject:
Reply with quote

Hello,

Suggest you speak with your system support people and make sure the current release of Syncsort is installed. . .
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2150
Location: At my coffee table

PostPosted: Wed Apr 29, 2009 2:07 am    Post subject:
Reply with quote

hariharan_82 wrote:
Yes. But I would want to do this througgh SYNCTOOL in one step.
Syncsort, Synctool, same difference.....
Quote:
Assuming that the last record is uniquely identifiable by content rather than just being the last record, adding a sequence number upon input to the data records and a sequence number of zero to the date record and just sort the file by the seqnum will get you what you want.
It won't be as fast as a straight copy, but, depending on the volume of records, sort will end up with basically two strings to merge to output. And it beats going through the file twice.
Back to top
View user's profile Send private message
subinraj

New User


Joined: 04 Sep 2007
Posts: 16
Location: Bangalore

PostPosted: Wed Apr 29, 2009 1:07 pm    Post subject:
Reply with quote

To select the last record from your input file

Code:
//S1   EXEC  PGM=ICETOOL                                         
//TOOLMSG   DD  SYSOUT=*                                         
//DFSMSG    DD  SYSOUT=*                                         
//SORTIN DD DSN=..INPUT FILE                                     
//SORTOUT DD SYSOUT=..OUTPUT FILE                                 
//TOOLIN DD *                                                     
 SELECT FROM(SORTIN) TO(SORTOUT) LAST ON(81,1,CH) USING(CTL1)     
/*                                                               
//CTL1CNTL DD *                                                   
 INREC OVERLAY(81:C'1')   



To select the Nth record
Code:
//S1   EXEC  PGM=SORT                           
//SORTIN DD DSN=.....INPUT                     
//SYSOUT DD SYSOUT=*                           
//SORTOUT DD SYSOUT=*                           
//SYSIN DD *                                   
 INREC OVERLAY(81:SEQNUM,3,ZD)             N   
 SORT FIELDS=COPY                          |   
 OUTFIL FNAMES=SORTOUT,INCLUDE=(81,3,ZD,EQ,3)   
/*                                           
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Apr 29, 2009 3:11 pm    Post subject:
Reply with quote

Hi,

Try this:
Code:
//STEP002 EXEC PGM=ICEMAN                   
//SYSOUT  DD  SYSOUT=*                     
//SORTIN  DD DSN= . . . input FB/80
//SORTOUT DD SYSOUT=*                       
//SYSIN   DD    *                           
  OPTION COPY                               
  OUTFIL REMOVECC,NODETAIL,                 
    TRAILER1=(1,80)                         
/*                                         
//*                                         
Back to top
View user's profile Send private message
subinraj

New User


Joined: 04 Sep 2007
Posts: 16
Location: Bangalore

PostPosted: Wed Apr 29, 2009 3:41 pm    Post subject:
Reply with quote

I tried this code in SYNCSORT FOR Z/OS 1.2.3.1

The following are the messages I get

TOOLMSG

Code:
SYT000I  SYNCTOOL RELEASE 1.5.3 - COPYRIGHT 2004  SYNCSORT INC.       
SYT001I  INITIAL PROCESSING MODE IS "STOP"                             
SYT002I  "TOOLIN" INTERFACE BEING USED                                 
                                                                       
          SELECT FROM(SORTIN) TO(SORTOUT) LAST ON(81,1,CH) USING(CTL1)
SYT020I  SYNCSORT CALLED WITH IDENTIFIER "0001"                       
SYT031I  NUMBER OF RECORDS PROCESSED: 000000000000005                 
SYT026I  NUMBER OF SELECTED RECORDS: 000000000000001                   
SYT030I  OPERATION COMPLETED WITH RETURN CODE 0                       
                                                                       
SYT004I  SYNCTOOL PROCESSING COMPLETED WITH RETURN CODE 0             


DFSMSG
Code:
SYNCSORT FOR Z/OS  1.2.3.1RI   U.S. PATENTS: XXXXXXX, XXXXXX   (C) 2005 SYNCSO
                                   
CTL1CNTL :                                                                     
 INREC OVERLAY(81:C'1')                                                       
PARMLIST :                                                                     
OPTION RESINV=0,ARESINV=0,MSGDDN=DFSMSG,SORTIN=SORTIN,SORTDD=CTL1,SORTOUT=SORTO
T,DYNALLOC,CMP=CLC,NOVLSHRT,EQUALS                                             
SORT FIELDS=(00081,0001,CH,A)                 
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Wed Apr 29, 2009 5:13 pm    Post subject:
Reply with quote

subinraj wrote:
I tried this code in SYNCSORT FOR Z/OS 1.2.3.1
And then what happend? Did it work the way you need?
Back to top
View user's profile Send private message
subinraj

New User


Joined: 04 Sep 2007
Posts: 16
Location: Bangalore

PostPosted: Wed Apr 29, 2009 6:07 pm    Post subject:
Reply with quote

Yes Anuj,

This was working for me.

Code:
//S1   EXEC  PGM=ICETOOL                                     
//TOOLMSG   DD  SYSOUT=*                                     
//DFSMSG    DD  SYSOUT=*                                     
//SORTIN DD *                                               
REC1                                                         
REC2                                                         
REC3                                                         
REC4                                                         
REC5                                                         
//SORTOUT DD SYSOUT=*                                       
//TOOLIN DD *                                               
 SELECT FROM(SORTIN) TO(SORTOUT) LAST ON(81,1,CH) USING(CTL1)
/*                                                           
//CTL1CNTL DD *                                             
 INREC OVERLAY(81:C'1')                                     



SORTOUT
Code:
REC5
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Sun May 03, 2009 2:43 pm    Post subject:
Reply with quote

Thanks for the follow-up . . . icon_smile.gif . Anyhow, I lost the track of this thread among many . . . icon_wink.gif
Back to top
View user's profile Send private message
Alissa Margulies

SYNCSORT Support


Joined: 25 Jul 2007
Posts: 500
Location: USA

PostPosted: Mon May 04, 2009 9:56 pm    Post subject:
Reply with quote

hariharan_82 wrote:
SYNCTOOL RELEASE 1.6.1 - COPYRIGHT 2007 SYNCSORT INC.
INITIAL PROCESSING MODE IS "STOP"
"TOOLIN" INTERFACE BEING USED

SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST
STATEMENT DOES NOT BEGIN WITH A VALID OPERATOR
OPERATION COMPLETED WITH RETURN CODE 12

PROCESSING MODE CHANGED FROM "STOP" TO "SCAN" DUE TO OPERATION FAILURE

SYNCTOOL PROCESSING COMPLETED WITH RETURN CODE 12

Woudl that mean something is not set up right wrt to the version of ICETOOL am havin?

Just as an FYI, support for SUBSET was included in SYNCTOOL release 1.6.2 (SyncSort for z/OS 1.3.2).
Back to top
View user's profile Send private message
Anuj Dhawan

Senior Member


Joined: 22 Apr 2006
Posts: 6258
Location: Mumbai, India

PostPosted: Tue May 05, 2009 3:17 pm    Post subject:
Reply with quote

Hi Alissa,

Thanks - I was about to send you a note to ask this. I was wondering that this:
Code:
//TOOLIN DD *                                               
 SELECT FROM(SORTIN) TO(SORTOUT) LAST ON(81,1,CH) USING(CTL1)
/* 
worked while this
Code:
//TOOLIN DD *
SUBSET FROM(IN) TO(OUT) KEEP INPUT LAST
/*
not, only change was "SUBSET".

Ad
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 syncsort: copy lines after the keyword shreya19 SYNCSORT 3 Fri Dec 02, 2016 9:47 am
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts CICS Roll back partially - Need to re... dwijadas CICS 4 Wed Nov 16, 2016 4:30 pm


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