View previous topic :: View next topic
|
Author |
Message |
Prasanthhere
Active User
Joined: 03 Aug 2005 Posts: 306
|
|
|
|
am having one doubt in jcl?
I am having a dataset having 10000 records and I want to delete the first or last 5000 records. How can I do it?
I won?t mention any keys in the sort statement. just my condition is I want to delete first or last 5000 records.. |
|
Back to top |
|
|
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
Hi,
Here is one of the method to copy the first 2 records.
Code: |
//PS030 EXEC PGM=SYNCTOOL
//SYSOUT DD SYSOUT=*
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
ABC
123
121
122
123
//FB1 DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) TO(FB1) USING(CTL1)
//CTL1CNTL DD *
SORT FIELDS=COPY
OUTFIL FNAMES=FB1,STARTREC=1,ENDREC=2
//*
|
Thanks
Krishy |
|
Back to top |
|
|
ralph_v
New User
Joined: 07 Jul 2005 Posts: 27
|
|
|
|
Hi ,
Just to clarify his question, the question was whether the records can be deleted .
ALthough as suggested by you we end with fulfilling the requirement but the actual requirement is "to delete". |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
I don't think we can delete the last 5000 rec since the last record count is dynamic.
We can use simple SORT or ICEMAN.
In Control Statement just mention 'SKIPREC=5000'
I,e you r skippign the first 5000 and reading from 5001 record.
~Vamsi |
|
Back to top |
|
|
shreevamsi
Active User
Joined: 23 Feb 2006 Posts: 305 Location: Hyderabad,India
|
|
|
|
Hi..
It is possible to Get the Last 5000 recs from Input to output.
But It can;t be done in single step.
The trick is to attach a sequence number to the records and sort them in descending order by the sequence number. That way, the last records end up at the front of the file and you can use STOPAFT or ENDREC to select the last n records. Unfortunately, those last n records will be in reverse order, so you have to sort them again in ascending order by the sequence number to get them back in their original order.
chek out the follwing link:
www-03.ibm.com/servers/storage/support/software/sort/mvs/tricks/srtmst03.html#t11 |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can now do this kind of thing quite easily using the new SUBSET operator of DFSORT's ICETOOL available with z/OS DFSORT V1R5 PTF UK90013 (July, 2008).
To delete the first 5000 records, you can use a DFSORT/ICETOOL job like this:
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(IN1) TO(OUT) INPUT REMOVE FIRST(5000)
/*
|
To delete the last 5000 records, you can use a DFSORT/ICETOOL job like this:
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(IN1) TO(OUT) INPUT REMOVE LAST(5000)
/*
|
For complete details on the new SUBSET function and the other new functions available with PTF UK90013, see:
Use [URL] BBCode for External Links |
|
Back to top |
|
|
|