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