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

DEletion of records


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Prasanthhere

Active User


Joined: 03 Aug 2005
Posts: 306

PostPosted: Tue Jun 13, 2006 10:59 am
Reply with quote

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
View user's profile Send private message
sril.krishy

Active User


Joined: 30 Jul 2005
Posts: 183
Location: hyderabad

PostPosted: Tue Jun 13, 2006 12:33 pm
Reply with quote

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
View user's profile Send private message
ralph_v

New User


Joined: 07 Jul 2005
Posts: 27

PostPosted: Tue Jun 13, 2006 1:34 pm
Reply with quote

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
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Tue Jun 13, 2006 1:45 pm
Reply with quote

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
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Tue Jun 13, 2006 2:51 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


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

PostPosted: Sat Sep 20, 2008 3:49 am
Reply with quote

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
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top