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

CRTDUPOBJ from a *LIBL object

If you need to create a copy of a file, or a data area, or other object in QTEMP (or anywhere else), but the source object's library is library list dependant, you know that CRTDUPOBJ needs to have the exact library where the object is to be duplicated from. If you need that kind of flexibility, all you need to do is use RTVOBJD to get the library.

The example creates the object AR809WK in QTEMP only if it can't find the file in QTEMP to clear(CPF3142 means that the file was not found).

DCL        VAR(&FILLIB) TYPE(*CHAR) LEN(10)

/* Create work file in QTEMP */                                       
             CLRPFM     FILE(QTEMP/AR809WK)                           
             MONMSG     MSGID(CPF3142) EXEC(DO)                       
             RTVOBJD    OBJ(*LIBL/AR809WK) OBJTYPE(*FILE) +           
                          RTNLIB(&FILLIB)                             
             CRTDUPOBJ  OBJ(AR809WK) FROMLIB(&FILLIB) OBJTYPE(*FILE) +
                          TOLIB(QTEMP) DATA(*NO)                      
             ENDDO 


Dig Deeper on RPG iSeries programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close