Save the current library and the library list of a job in order to use it again later. Some times -- especially when from the same menu run different applications -- you need to replace your library list with a new one, but later you want to use the old library list and the current library again.
Sometimes, however, you can't add or remove libraries from the library list. The CL Program LIBLIST can help you to save the current library and the library list into variables and restore them again when you need them. The CLP can be use as a called separate program or as a portion of an existing CL Program.
PGM DCL VAR(&LIBL) TYPE(*CHAR) LEN(275)
DCL VAR(&CURLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&COUNT1) TYPE(*DEC)LEN(3 0)
DCL VAR(&COUNT2) TYPE(*DEC) LEN(3 0) +
VALUE(-10)
RTVJOBA USRLIBL(&LIBL)CURLIB(&CURLIB)
/**** INSERT HERE YOUR STATEMENTS
CHGVAR VAR(&COUNT1) VALUE(1)
CHGLIBL LIBL(%SST(&LIBL &COUNT1 10)) +
CURLIB(&CURLIB)
LOOP:CHGVAR VAR(&COUNT1) VALUE(&COUNT1 +
+11
CHGVAR VAR(&COUNT2) VALUE(&COUNT2 +11)
IF COND(%SST(&LIBL &COUNT1 10) +
*NE ' ' THEN(DO)
ADDLIBLE LIB(%SST(&LIBL &COUNT1 10)) +
POSITION(*AFTER +
%SST(&LIBL &COUNT2 10))
GOTO LOOP ENDDO END: ENDPGM
This was first published in December 2001