Empty a file without deleting the file.
-
- New Member
- Posts: 6
- Joined: Sun Apr 27, 2014 10:47 am
Empty a file without deleting the file.
Hi,
In a JOb step I need to delete the content of a dataset but I don't want to delete the dataset itself. How is it possible to do? Can IDCAMS or IEFBR14 do this? Please help.
In a JOb step I need to delete the content of a dataset but I don't want to delete the dataset itself. How is it possible to do? Can IDCAMS or IEFBR14 do this? Please help.
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Empty a file without deleting the file.
Hi,
You could delete and recreate the dataset
You could delete and recreate the dataset
zprogrammer
Re: Empty a file without deleting the file.
What happened when you tried?Can IDCAMS or IEFBR14 do this?
You must understand about IEFBR14 - it does absolutely nothing, zilch, zero, sod all apart from set a return code of zero.
You could write a little program that will open the dataset in output mode and then close it again. That should reset the end-of-file indicator. And, yes, you can make it generic.
Regards
Nic
Nic
-
- Global Moderator
- Posts: 837
- Joined: Wed Sep 11, 2013 3:57 pm
Re: Empty a file without deleting the file.
the question is legitimate,
I have seen many places where the users can update a dataset but cannot delete/allocate it
so for them there might be the need to <empty> a dataset
for a VSAM cluster only if it has been defined with the REUSE attribute
for a PS dataset a simple iebgener with a DUMMY input DD will do
I have seen many places where the users can update a dataset but cannot delete/allocate it
so for them there might be the need to <empty> a dataset
for a VSAM cluster only if it has been defined with the REUSE attribute
for a PS dataset a simple iebgener with a DUMMY input DD will do
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: Empty a file without deleting the file.
Hi Enrico,
Ok,I understand. In such cases DUMMY overwrite would come handy
Ok,I understand. In such cases DUMMY overwrite would come handy
zprogrammer
- Robert Sample
- Global Moderator
- Posts: 1900
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Empty a file without deleting the file.
IEFBR14 cannot do this -- it does not open the data set.
For VSAM, the REUSE option comes into play. Without it, what you want to do cannot be done. For sequential, IDCAMS can -- REPRO from a DD DUMMY to the data set with DISP=OLD specified.
For VSAM, the REUSE option comes into play. Without it, what you want to do cannot be done. For sequential, IDCAMS can -- REPRO from a DD DUMMY to the data set with DISP=OLD specified.
-
- New Member
- Posts: 5
- Joined: Wed Jul 06, 2016 8:59 pm
Re: Empty a file without deleting the file.
You may use the below JCL
Code: Select all
//EMPTY EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=TSUE34S.ANKIT.Y2017,DISP=SHR ----> Input file with No records and same DCB Attributes
//SORTOUT DD DSN=TSUE34S.ANKIT.G2017,DISP=OLD ----> File to be emptied out, see the DISP used
//STDOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
- Robert Sample
- Global Moderator
- Posts: 1900
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Empty a file without deleting the file.
raazankeet, why not instead of having to allocate an empty data set? And your SORT JCL is no improvement upon the previously suggested IDCAMS or IEBGENER solutions -- you've merely provided another way to do the same thing.requires fewer lines of coding and no parameter to do the same thing.
Also, after a year and a half the likelihood of your solution being helpful is pretty close to zero. And there are plenty of other examples in this and other fora on how to delete the records in a data set without deleting the data set. So other than raising your posting count, you haven't really contributed much to the topic.
Code: Select all
//EMPTY EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DUMMY,LRECL=?,BLKSIZE=?
//SORTOUT DD DSN=TSUE34S.ANKIT.G2017,DISP=OLD ----> File to be emptied out, see the DISP used
//STDOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
Code: Select all
//EMPTY EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
//SYSUT1 DD DUMMY,LRECL=?,BLKSIZE=?
//SYSUT2 DD DISP=OLD,DSN=TSUE345.ANKIT.G2017
Also, after a year and a half the likelihood of your solution being helpful is pretty close to zero. And there are plenty of other examples in this and other fora on how to delete the records in a data set without deleting the data set. So other than raising your posting count, you haven't really contributed much to the topic.
-
- New Member
- Posts: 5
- Joined: Wed Jul 06, 2016 8:59 pm
Re: Empty a file without deleting the file.
I'm not sure how the posting count will help me or anyone by any means!
I replied what came to my mind after seeing the question. You may agree that there are multiple ways to solve each problem.
Which way to go, this depends on many factors.
However, I must say that I was not aware of the
Code: Select all
LRECL=?,BLKSIZE=?
Thanks for this!!!
- Robert Sample
- Global Moderator
- Posts: 1900
- Joined: Fri Jun 28, 2013 1:22 am
- Location: Dubuque Iowa
Re: Empty a file without deleting the file.
The question marks are filled in with the appropriate values, of course; you don't want to try using LRECL=? in an actual job.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute