Question

We control on what objects our programs on the as400 work, by running them with different liblists. But some operations cannot be directly controlled by this. Therefore, my program needs to read the liblist and decide on some of the libraries in it, how to act.

I could not find any api to read the liblist entries from within a program. What I would expect, is some kind of api that lets me iterate through the liblist entries by priority or gives me an array with them in the order given by the liblist. I'd prefer RPG or CL if possible, but other ILE languages are available, too.

(If you wonder, why I'm trying to do this, I asked another question, that explaines the enclosing problem I'm faced with: How can I create a DTAQ in one of two different libs, controlled by the jobs liblist? But the liblist parsing is an approach to solve that one and is an individual problem).

Was it helpful?

Solution

You can use the QUSRJOBI API to retrieve the library list for a job. You can also use the CL command ADDLIBLE and monitor for error message CPF2103 (library already exists in library list).

OTHER TIPS

The List Objects (QUSLOBJ) API can be used to retrieve the library list.

Object and library name
When *ALLUSR is specified with a library name of *LIBL and an object type parameter of *LIB, a list of all user libraries in the thread's library name space is returned. When *LIBL is specified, the auxiliary storage pool (ASP) device name must be an asterisk (*) if the auxiliary storage pool (ASP) control parameter is specified. Refer to *ALLUSR in the description of the second 10 characters of this parameter for a definition of user libraries.

The Change Library List (QLICHGLL) API can be used to change the library list.

The RTVJOBA command can retrieve the SYSLIBL, CURLIB, and USRLIBL.


The book APIs at work, Chapter 3, List APIs has a lot of information that may help you.

A simpler alternative approach might be worthwhile, depending on your situation. If you know the target libraries in advance, perhaps you could create a data area in each of those libraries, containing the library name. Your program will read whichever data area it finds first on the library list, and will give you the name of the library for you to create your data queue.

It's not sophisticated, but it is effective and very simple, and also therefore easier to code/debug/maintain.

Kratenko, if you want simpler and lesser code alternative than API. Create simple CL pgm that you can call within your rpg. Your cl can have RTVJOBA (there's parm to get libl). You might get many libs from that, and you need to parse and identify the specific lib you want? About identifying you must know one of the qualifiers. Do you want the lib where your pgm runs or the lib where "some" file resides? If yes on any, then you can use RTVOBJD to get specific lib. Then use that lib in your CRTDTAQ cmds.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top