Page 1 of 1

Delete alias

PostPosted: Wed Nov 05, 2014 4:25 pm
by brummm
Hello everybody.

I need to modify the dataset related to a ALIAS.

Since I did not found any "MODIFY"||"UPDATE"||"ALTER" command, I'm trying to delete a alias and then redefine it bellow as follows.

//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
 DELETE <alias name> ALIAS
 DEFINE ALIAS (NAME(<alias name>) -
 RELATE(<dataset name>))
/*   


This is working, but, if the ALIAS isn't created yet, it gives me a RC 8 on the deletion, which says that "ENTRY <aliasname> NOT FOUND".

Is there a way to test if the alias exists and then delete it only if it's true?

---------

Or there is any better solution to do what I need to do? That is:
I'm recovering information that was migrated from DB2 to disk/tape through weekly PROC. The data to be recovered is separated by months and the dataset names follows this organization.
But the rules for the recovery (such as time frame, transaction type, values, etc) are stored on a DB2 table. In one week, we could have three months to recover and in the next week, none.

Since the datasets that are source to my recovery are not a constant, I need to make its names available to JCL. First, my solution was defining a dataset on a first JOB that was written from a cobol program with only one line that was:
 SET DATEDS=YYYYMM

and then include it on a second job. But here on my shop, include is not allowed.

Then I tryed the solution above with IDCAMS.

Thanks in advance and sorry by bad english.

Re: Delete alias

PostPosted: Wed Nov 05, 2014 7:29 pm
by NicC
Just ignore the RC=8 from the delete, SET MAXCC=0 and then do the define. If the define fails then that is the return code that is given in your output.

Re: Delete alias

PostPosted: Thu Nov 06, 2014 3:42 pm
by brummm
NicC wrote:Just ignore the RC=8 from the delete, SET MAXCC=0 and then do the define. If the define fails then that is the return code that is given in your output.


Let me see if I understood it correctly.

What I should do (and did) is:
SET MAXCC=0
DEL (<ALIASNAME>) ALIAS
DEFINE(NAME(<ALIASNAME) RELATE(DATASETNAME))


And then, if the DEFINE fails, I get the return code of the DEFINE instruction only. No need to SET MAXCC to another value after DELETE and before DEFINE?

If this is right and I have to do, lets say, four deletes, do I have to SET MAXCC before every DELETE instruction?

Re: Delete alias

PostPosted: Thu Nov 06, 2014 8:02 pm
by BillyBoyo
A better way to go at it is to use the IF available. Then you can be in control of things, rather than hiding a problem.

Try a quick internet search for - idcams modal commands. I can't do a link for you as it is refusing to connect to the IBM site at the moment :-)

Re: Delete alias

PostPosted: Thu Nov 06, 2014 8:02 pm
by Terry Heinze
I use:
       IF         LASTCC LE 08 THEN
           DO
               SET MAXCC EQ 00
           END

after a single IDCAMS command and prior to a DEFINE and
       IF          MAXCC LE 08 THEN
           DO
               SET MAXCC EQ 00
           END

after multiple IDCAMS commands and prior to a DEFINE.

Re: Delete alias

PostPosted: Thu Nov 06, 2014 8:15 pm
by BillyBoyo
That's the stuff I mean, Terry. "modal commands" it's called, though not bothered to find out why :-)