Problem solve Get help with specific problems with your technologies, process and projects.

Lacking file authority in CRTDUPOBJ

So you have a report everyone uses, but not everyone has authority to the production files for update. Here's a workaround.

So you have a report everyone uses, but not everyone has authority to the production files for update (such as the CEO and salesmen). There is a workaround. Monitor for no authority to the file, CPF2182 and use CPYF.

Note the use of a data area to get the library. Have a data area for production and test environment. That way the same CL can run in production or test but point to different libraries for files.

Code:

             DCL        &LIB1 *CHAR 10                               
                                                                    
            RTVDTAARA  (LIBLST (31 10)) &LIB1 /* Production Files */ 
                                                                    
* SET LIB LIST FOR WORK FILE IN QTEMP                            */ 
   RMVLIBLE   QTEMP   
   MONMSG     CPF0000 
         
   ADDLIBLE   QTEMP 
   MONMSG     CPF0000    
                                                                    
   CRTDUPOBJ  OBJ(BFPKPF49) FROMLIB(&LIB1) OBJTYPE(*FILE) +         
            TOLIB(QTEMP) DATA(*NO)                                  
   MONMSG   CPF2182 EXEC(DO)   /* No Authority To Dup File  */      
            CPYF       &LIB1/BFPKPF49 QTEMP/BFPKPF49 CRTFILE(*YES) + 
                         NBRRCDS(1)  MBROPT(*ADD)                   
            CLRPFM     QTEMP/BFPKPF49                               
            ENDDO                                                 

Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close