View previous topic :: View next topic
|
Author |
Message |
hariharan_82
New User
Joined: 18 Apr 2007 Posts: 23 Location: Chennai
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
hariharan_82
New User
Joined: 18 Apr 2007 Posts: 23 Location: Chennai
|
|
|
|
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 |
|
|
hariharan_82
New User
Joined: 18 Apr 2007 Posts: 23 Location: Chennai
|
|
|
|
Sorry about the spelling keyboad is all screwed up |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
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 |
|
|
hariharan_82
New User
Joined: 18 Apr 2007 Posts: 23 Location: Chennai
|
|
|
|
So is there no way to do this using SYNCTOOL and SYNCSORT? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
hariharan_82
New User
Joined: 18 Apr 2007 Posts: 23 Location: Chennai
|
|
|
|
Yes. But I would want to do this througgh SYNCTOOL in one step. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you speak with your system support people and make sure the current release of Syncsort is installed. . . |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
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 |
|
|
subinraj
New User
Joined: 04 Sep 2007 Posts: 16 Location: Bangalore
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
subinraj
New User
Joined: 04 Sep 2007 Posts: 16 Location: Bangalore
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
subinraj
New User
Joined: 04 Sep 2007 Posts: 16 Location: Bangalore
|
|
|
|
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
|
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Thanks for the follow-up . . . . Anyhow, I lost the track of this thread among many . . . |
|
Back to top |
|
|
Alissa Margulies
SYNCSORT Support
Joined: 25 Jul 2007 Posts: 496 Location: USA
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
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 |
|
|
|