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

Delete VSAM or flat file using a single rexx command


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Vinay N.G

New User


Joined: 15 Sep 2008
Posts: 36
Location: Bangalore

PostPosted: Tue May 12, 2009 9:12 pm
Reply with quote

Hi,

1) Please let me know if we can delete any VSAM or Flat file using the same command in REXX.

2) Is it possible for a REXX program to differentiate the input files
between VSAM and a flat file. If so how to find out whether the input file is a VSAM file or flat file(PS).
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Tue May 12, 2009 9:34 pm
Reply with quote

Use the LISTDSI built-in function to check the DSORG. Read Rexx Reference manual for more information.

And to delete a dataset, use the delete command
Code:
Address TSO 'DELETE ...'


I am not sure what you mean by 'using the same command in REXX.'
Back to top
View user's profile Send private message
Vinay N.G

New User


Joined: 15 Sep 2008
Posts: 36
Location: Bangalore

PostPosted: Tue May 12, 2009 9:43 pm
Reply with quote

Is it possible to track whether the delete is successful or not.. If so how to track it.

What if dataset is not present and we are trying to delete it.

I mean, in JCL if it happens like that, then we will set maxcc=0 right , in the same way can we don anything here in REXX so that it doesnt throw any error message if it tries to delete the dataset which is not catalouged.
Back to top
View user's profile Send private message
acs_amit

New User


Joined: 30 Apr 2009
Posts: 14
Location: Noida

PostPosted: Tue May 12, 2009 11:45 pm
Reply with quote

Suppose your dataset is:
DSN.A = 'A.B.C'

/*then to delete the dataset.. use*/

Address TSO
"delete '"||DSN.A||"'"


/*Now to check whether delete is successful use SYSDSN command..foe ex..*/

if sysdsn("'"||DSN.A||"'") = 'OK' THEN
SAY 'PROBLEM WITH DELETING THE DATASET'
Else
SAY 'DATASET HAS BEEN DELETED'

/* search for SYSDSN command in manuals.. */

I hope this will solve your query...
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed May 13, 2009 12:03 am
Reply with quote

Hello,

I believe that will not work if the dataset does not exist at the beginning. . . The delete will fail. . .
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2546
Location: Silicon Valley

PostPosted: Wed May 13, 2009 12:58 am
Reply with quote

use SYSDSN first to make sure it exits.

After DELETE, check the return code.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Wed May 13, 2009 1:27 am
Reply with quote

acs_amit wrote:
Suppose your dataset is:
DSN.A = 'A.B.C'

/*then to delete the dataset.. use*/

Address TSO
"delete '"||DSN.A||"'"


/*Now to check whether delete is successful use SYSDSN command..foe ex..*/

if sysdsn("'"||DSN.A||"'") = 'OK' THEN
SAY 'PROBLEM WITH DELETING THE DATASET'
Else
SAY 'DATASET HAS BEEN DELETED'

/* search for SYSDSN command in manuals.. */

I hope this will solve your query...


I use a different logic (one that hopefully works):
Code:
DSN.A = "'A.B.C'"

/* If the file is here, remove it */
/* If the delete fails, the program is ended */

If SYSDSN(DSN.A) = 'OK' Then
   Address TSO "DELETE "DSN.A
Isn't it easier?
The error can be trapped to allow housekeeping and a proper message.
Code:
SIGNAL ON ERROR
DSN.A = "'A.B.C'"

/* If the file is here, remove it */
/* If the delete fails, send appropriate message */

If SYSDSN(DSN.A) = 'OK' Then Do
   Address TSO "DELETE "DSN.A
   Say 'File 'DSN.A' has been deleted'
End

ERROR:
Say 'The return code from the command on line 'Sigl' is 'RC
Say 'Command is: 'SourceLine(Sigl)
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 -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts RACF - Rebuild SETROPTS command which... All Other Mainframe Topics 3
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
Search our Forums:

Back to Top