Page 1 of 1

Correction needed

PostPosted: Thu Sep 06, 2012 7:22 pm
by balamurali cl
 /* REXX */                                                 
 DUH_USER = USERID()                                         
 DSN=DUH_USER'.DATASET.LIST'                                 
 Y = DSNSEE(DSN)                                             
 ADDRESS TSO                                                 
 'ALLOC F(OUT) DA('DSN') NEW TRACKS SPA(60 45) ' ,           
 ' LRECL(80) RECFM(F B) BLKSIZE(9040) DSORG(PS)'             
 IF RC > 0 THEN                                             
   DO                                                       
     SAY 'ALLOCATION FAILED RC=:' RC                         
     ADDRESS TSO 'FREE F(OUT)'                               
   END                                                                 
     EXIT                                                   
 DSNSEE: PROCEDURE                                                                     
         PARSE ARG DSN                                       
         DSN = "'"DSN"'"                                     
         ADDRESS TSO                                         
         X = SYSDSN(DSN)                                     
         IF X ¬= 'OK' THEN RETURN DSN                       
         ELSE                                               
            DO                                               
              ADDRESS TSO DELETE DSN                         
              IF RC = 0 THEN SAY 'DELETED'                   
              ELSE SAY 'NOT DELETED'                         
              RETURN DSN                                     
            END                                             


In the above code when a particular user executes with 'EX' option then it checks if the dataset userid.data.list exist or not. If exits it deletes and then allocates. If it doent exists it allocates.

But here it checks it whethere the dataset exist and gets deleted. But when allocating it tells the dataset exits.because if the user id is A for example. The dataset it checks for is 'A.DATASET.LIST' but while allocating it is 'A.A.DATASET.LIST'.

here is the error:

IKJ56893I DATA SET A.A.DATASET.LIST NOT ALLOCATED+
IGD17101I DATA SET A.A.DATASET.LIST
NOT DEFINED BECAUSE DUPLICATE NAME EXISTS IN CATALOG
RETURN CODE IS 8 REASON CODE IS 38 IGG0CLEH
ALLOCATION FAILED RC=: 12
IKJ56247I FILE OUT NOT FREED, IS NOT ALLOCATED

Re: Correction needed

PostPosted: Thu Sep 06, 2012 7:32 pm
by Akatsukami
Remember that if a data set name is not enclosed in single quotes in TSO, it will be prefixed with the specified user's HLQ (usually, but not always, the TSO ID). Change the ALLOCATE command to:
"ALLOC F(OUT) DA('"DSN"') NEW TRACKS SPA(60 45) " ,           
" LRECL(80) RECFM(F B) BLKSIZE(9040) DSORG(PS)"       

Re: Correction needed

PostPosted: Thu Sep 06, 2012 7:40 pm
by balamurali cl
Superb...Thanks for the gun point...it worked now)