Empty a file without deleting the file.

JES2/3, JCL, utilities.

Topic author
Rahul Dhoble
New Member
Posts: 6
Joined: Sun Apr 27, 2014 10:47 am

Empty a file without deleting the file.

Postby Rahul Dhoble » Tue Nov 03, 2015 11:02 am

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.




zprogrammer
Global Moderator
Global Moderator
Posts: 603
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars
Has thanked: 7 times
Been thanked: 7 times

Re: Empty a file without deleting the file.

Postby zprogrammer » Tue Nov 03, 2015 1:35 pm

Hi,

You could delete and recreate the dataset


zprogrammer


nicc
Global Moderator
Global Moderator
Posts: 542
Joined: Wed Apr 23, 2014 8:45 pm
Been thanked: 11 times

Re: Empty a file without deleting the file.

Postby nicc » Tue Nov 03, 2015 2:21 pm

Can IDCAMS or IEFBR14 do this?


What happened when you tried?

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


enrico-sorichetti
Global Moderator
Global Moderator
Posts: 813
Joined: Wed Sep 11, 2013 3:57 pm
Been thanked: 68 times

Re: Empty a file without deleting the file.

Postby enrico-sorichetti » Tue Nov 03, 2015 5:24 pm

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


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 8-)


zprogrammer
Global Moderator
Global Moderator
Posts: 603
Joined: Wed Nov 20, 2013 11:53 am
Location: Mars
Has thanked: 7 times
Been thanked: 7 times

Re: Empty a file without deleting the file.

Postby zprogrammer » Tue Nov 03, 2015 7:08 pm

Hi Enrico,

Ok,I understand. In such cases DUMMY overwrite would come handy


zprogrammer

Online
User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1256
Joined: Fri Jun 28, 2013 1:22 am
Location: East Dubuque Illinois
Has thanked: 2 times
Been thanked: 90 times

Re: Empty a file without deleting the file.

Postby Robert Sample » Tue Nov 03, 2015 11:50 pm

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.




raazankeet
New Member
Posts: 5
Joined: Wed Jul 06, 2016 8:59 pm
Been thanked: 1 time

Re: Empty a file without deleting the file.

Postby raazankeet » Sat Jul 15, 2017 1:33 am

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



Online
User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1256
Joined: Fri Jun 28, 2013 1:22 am
Location: East Dubuque Illinois
Has thanked: 2 times
Been thanked: 90 times

Re: Empty a file without deleting the file.

Postby Robert Sample » Sat Jul 15, 2017 1:50 am

raazankeet, why not

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
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.

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
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.




raazankeet
New Member
Posts: 5
Joined: Wed Jul 06, 2016 8:59 pm
Been thanked: 1 time

Re: Empty a file without deleting the file.

Postby raazankeet » Sun Jul 16, 2017 10:00 pm

Robert Sample wrote:Source of the post So other than raising your posting count, you haven't really contributed much to the topic.


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!!!



Online
User avatar

Robert Sample
Global Moderator
Global Moderator
Posts: 1256
Joined: Fri Jun 28, 2013 1:22 am
Location: East Dubuque Illinois
Has thanked: 2 times
Been thanked: 90 times

Re: Empty a file without deleting the file.

Postby Robert Sample » Mon Jul 17, 2017 2:47 am

The question marks are filled in with the appropriate values, of course; you don't want to try using LRECL=? in an actual job.




Return to “JCL - Job Control Language.”

Who is online

Users browsing this forum: CommonCrawl [Bot] and 0 guests