Tuesday, June 10, 2008

Simple check for IFS objects existence:

Another simple way to check for the existence of an IFS object --without having to dig into IFS APIs -- is to use the DSPLNK command with the printer output option. The command will generate CPFA0A9 if the object(s) do not exist.
The only drawback to this method is that it will create a spool file listing the object(s) -- if they actually exist. But you could encapsulate it in a CL where you could override and hold the spool file before issuing the DSPLNK command, then delete it when done.
OVRPRTF FILE(QSYSPRT) HOLD(*YES)
DSPLNK OBJ('/path/objectname') OUTPUT(*PRINT) OBJTYPE(*ALL)
DETAIL(*BASIC)
DSPOPT(*USER)
DLTSPLF FILE(QSYSPRT) SPLNBR(*LAST)

No comments: