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

Copy only the last record from file with Syncsort


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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: 2146
Location: At my coffee table

PostPosted: Tue Apr 28, 2009 9:30 pm
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 Developer


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

PostPosted: Tue Apr 28, 2009 10:45 pm
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:

Use [URL] BBCode for External Links
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
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
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 Developer


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

PostPosted: Tue Apr 28, 2009 11:14 pm
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
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: 3156
Location: Tucson AZ

PostPosted: Wed Apr 29, 2009 12:16 am
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
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

Moderator Emeritus


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

PostPosted: Wed Apr 29, 2009 12:39 am
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: 2146
Location: At my coffee table

PostPosted: Wed Apr 29, 2009 2:07 am
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
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

Superior Member


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

PostPosted: Wed Apr 29, 2009 3:11 pm
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
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

Superior Member


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

PostPosted: Wed Apr 29, 2009 5:13 pm
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
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

Superior Member


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

PostPosted: Sun May 03, 2009 2:43 pm
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: 496
Location: USA

PostPosted: Mon May 04, 2009 9:56 pm
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

Superior Member


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

PostPosted: Tue May 05, 2009 3:17 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 8
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
Search our Forums:

Back to Top