I’m pretty sure a current library always exists.
Type DSPLIBL and Enter from the command line. It will show you your library list. The entry with a type of “CUR” is your current library list. To change it, type CHGCURLIB from the command line, prompt it, and enter the library you want to be current. Hope this helps.
How to see if a CERTAIN library is in you library list.
/* see if library MyLib is in the library list */
ADDLIBLE LIB(MyLib) POSITION(*LAST)
MONMSG MSGID(CPF2103) EXEC(DO)
CHGVAR VAR(&INLIBL) VALUE(Y)
CHGVAR VAR(&INLIBL) VALUE(N)
You will not see a *CUR library on your library list if your profile has *CRTDFT as the default for current library. Any commands that access or create objects in *CURLIB in this case will default to QGPL.
You can scan the system, current library and user library lists of a job using the RTVJOBA command from the appropriate parameters to look for a specific library or libraries using the QCLSCAN function. This also can be done in a HLL program using the appropriate API and a scan function. Check the Program and CL Command API manual for the specific examples.
I assume you want to know if a “specific” lib is available. If that is what you want you can do if defined …
In a CLLE pgm
ADDLIBLE LIB(libname) POSITION(position)
The libray name can also be code as a variable