MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Delete all records from dataset

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF
View previous topic :: View next topic  
Author Message
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Wed Aug 11, 2004 12:21 pm    Post subject: Delete all records from dataset Reply with quote

I have a REXX program that reads records from an input file. If the record meets certain criteria, the program writes (EXECIO DISKW) the record to an output file. Since the output file is allocated with DISP=OLD, the old records in the output file will be overwritten. However, if none of the records satisfies the criteria, I want to delete all the old records from the output file (file with 0 record). I can write an EDIT macro to delete all the records:
Code:

address ISPEXEC
"LMINIT DATAID(ID) DDNAME(OUTFILE)"
"EDIT DATAID(&ID) MACRO(EMPTYDS)"
"LMFREE DATAID(&ID)"


/* REXX
    EMPTYDS macro to delete all records from dataset */
address 'ISREDIT'
'MACRO'
'DELETE ALL .ZFIRST .ZLAST'
'SAVE'
'END'

Is there a simpler way to delete all the records?
Back to top
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Wed Aug 11, 2004 2:20 pm    Post subject: Reply with quote

I prefer SORT to empty a dataset:
Code:

"ALLOC DD(SORTIN) DA('THE.DATASET') SHR REU"
"ALLOC DD(SORTOUT) DA('THE.DATASET') SHR REU"
"ALLOC DD(SYSOUT) DA(*) REU"
"ALLOC DD(SYSIN) NEW REU RECFM(F B) LRECL(80)"
Queue "  OPTION COPY"
Queue "  OMIT COND=ALL"
Queue ""
"EXECIO * DISKW SYSIN (FINIS"
"CALL *(SORT)"
"FREE DD(SORTIN SORTOUT SYSIN SYSOUT)"
Back to top
View user's profile Send private message
ofer71
Intermediate


Joined: 12 Feb 2003
Posts: 358
Topics: 4
Location: Israel

PostPosted: Wed Aug 11, 2004 2:42 pm    Post subject: Reply with quote

Here is a function I wrote while ago:
Code:
/*------------------------------- REXX -------------------------------
 * PROGRAM   : EMPTYDSN                                               
 * FUNCTION  : EMPTY DATASET                                         
 * AUTHOR    : OFER                                                   
 * DATE      : 03/06/03                                               
 * HOW TO USE: X = EMPTYDSN(DSNAME)                                   
 *           :                                                       
 *------------------------------------------------------------------*/
                                                                     
ARG DSN                                                               
IF DSN = ' ' THEN DO                                                 
  EXITRC = 99                                                         
  SIGNAL ENDEXEC                                                     
END                                                                   
                                                                     
DSN = STRIP(DSN,"B","'")                                             
                                                                     
D = OUTTRAP('DUMMY.')                                                 
  ADDRESS TSO "REPRO INDA('"DSN"') OUTDA('"DSN"') COUNT(0)"           
D = OUTTRAP('OFF')                                                   
                                                                     
EXITRC = RC                                                           
                                                                     
ENDEXEC:                                                             
EXIT EXITRC                                                           


O.
________
silversurfer reviews


Last edited by ofer71 on Sat Feb 05, 2011 11:19 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Aug 11, 2004 3:46 pm    Post subject: Reply with quote

Code:

"EXECIO 0 DISKW myoutdd ... (OPEN"
"EXECIO 0 DISKW myoutdd ... (FINIS"


The first one will open and put the 'file-pointer' before the first record. Next, one will write an EOF marker and close the dataset.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Wed Aug 11, 2004 3:51 pm    Post subject: Reply with quote

Maybe, this will work too.
Code:

"EXECIO 0 DISKW myoutdd ... (OPEN FINIS"

_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Thu Aug 12, 2004 1:12 am    Post subject: Reply with quote

If you are already doing the LMINIT, just use an LMOPEN for output instead of the EDIT.
(You don't need to code the LMCLOSE --LMFREE will do that for you)
I suspect Cogito-Ergo-Sum's solution is a little faster, but it would not be significant.
Back to top
View user's profile Send private message Visit poster's website
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Thu Aug 12, 2004 8:35 am    Post subject: Reply with quote

Thank you all for the excellent solutions. Smile
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Thu Aug 12, 2004 2:15 pm    Post subject: Reply with quote

You are welcome.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
coolman
Intermediate


Joined: 03 Jan 2003
Posts: 283
Topics: 27
Location: US

PostPosted: Fri Aug 13, 2004 4:12 pm    Post subject: Reply with quote

Cogito,

Do you still need a "OPEN" out there?
________
DT175


Last edited by coolman on Sat Feb 05, 2011 1:39 am; edited 1 time in total
Back to top
View user's profile Send private message
Cogito-Ergo-Sum
Advanced


Joined: 15 Dec 2002
Posts: 637
Topics: 43
Location: Bengaluru, INDIA

PostPosted: Fri Aug 13, 2004 4:22 pm    Post subject: Reply with quote

Which one? My second post? (Not sure I understood you correctly...)

That post is just another suggestion; a follow-up to the first one.

In either case, the idea is to open and read zero records. Then, write 0 records again leading to deletion of records.

It is in the manual.
_________________
ALL opinions are welcome.

Debugging tip:
When you have eliminated all which is impossible, then whatever remains, however improbable, must be the truth.
-- Sherlock Holmes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> TSO and ISPF All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group