AS/400 Library Lists in Parallel Environments
by Ted Holt
Make separate environments a snap with library lists.
Setting up a test environment on my old System/36 was such a pain that I was tempted at times to forego testing after making a small modification to a program. This was because I had to first copy the production files which were to be modified or contain test data. Then I had to copy an OCL procedure and change the LABEL parameter of the FILE statements. Oh, and if I overlooked a FILE statement that needed to be changed...well, maybe it wouldn't do too much damage. Sometimes it almost seemed more trouble than it was worth.
Running parallel production environments on the S/36 was a challenge, too. I once wrote a payroll system in which the operator had to put a two-digit system number in the LDA before starting a run. My procedures were full of such hard-to-read expressions as LABEL-PR?L'1,2'?. MEM. It worked fine, but it was not foolproof. After all, any HLL program or OCL procedure can change the LDA. I could have had serious problems if, during the processing of system 01, something (an inadequately tested program, perhaps) had accidentally placed "02" in the first two positions of the LDA.
The AS/400 does not require such roundabout methods of testing programs and running parallel production environments. Since OS/400 stores files in libraries, you can have all the parallel environments you wish. You just have to tell the system which libraries to use, and you do so with library lists.
Definition
A library list is an ordered sequence of library names which the system uses to search for an unqualified object. That is to say, if you do not specify which library an object is in, the system will look for it, starting at the top of the library list and working toward the bottom.
In the command "CALL PGM(ARLIB /AR100)", program AR100 is qualified. The system will look for program AR100 in ARLIB even if ARLIB is not in the library list. Program AR100 is unqualified in the command "CALL PGM(AR100)". When the call is executed, the system will scan the library list from top to bottom, looking for a library which contains a program called AR100. There may be a program of that name in more than one library. The system will run the first one it finds.
The same thing happens when the system looks for other types of objects, such as files, data areas, and output queues, since AS/400 libraries can contain any type of object (except for other libraries).
The library list actually consists of two portions: a system portion (defined by system value QSYSLIBL) and a user portion (defined by system value QUSRLIBL). The system portion contains the names of libraries which are part of OS/400, although you can modify this part of the library list if you wish. this article will examine the user portion, which can contain up to twenty-five library names.
Each job has its own library list. When an interactive job begins, its library list is set to whatever is in the system value QUSRLIBL. This may be overridden by the job description. You can change the library list with commands Edit Library List (EDTLIBL), Change Library List (CHGLIBL), Add Library List Entry (ADDLIBLE), and Remove Library List Entry (RMVLIBLE). Since you probably do not want users to key in these commands, place a CHGLIBL command in their sign-on programs in order to give each user access to the libraries he or she needs.
Batch jobs can also use the CHGLIBL, ADDLIBLE, and RMVLIBLE commands to set the library list, but that is rarely desirable. A batch job obtains its library list from the INLLIBL parameter of the Submit Job command (SBMJOB). You can include the libraries needed for the job, but usually you are better off to use the default value, *JOBD. This will cause the job to use the library list defined in the job description under which it was submitted.
An Example Environment
To illustrate how library lists can drive a system, let's pretend we work in a shop in Largeville, USA. We have one remote location in Smalltown. Both offices use the same software, but each has its own files.
Library GENERAL holds the objects used by both locations. This is where we put the programs. GENERAL also contains any files, data areas, or other objects which the two share. 1 lists the objects in GENERAL.
Library GENERAL holds the objects used by both locations. This is where we put the programs. GENERAL also contains any files, data areas, or other objects which the two share. Figure 1 lists the objects in GENERAL.
Library LARGEVILLE contains objects used only by the Largeville office. Library SMALLTOWN works the same way, but for our remote location. 2 lists the objects found in these libraries. That is, each library contains all of these objects.
Library LARGEVILLE contains objects used only by the Largeville office. Library SMALLTOWN works the same way, but for our remote location. Figure 2 lists the objects found in these libraries. That is, each library contains all of these objects.
3 shows the library lists needed for these two locations. You can see that they are almost identical.
Figure 3 shows the library lists needed for these two locations. You can see that they are almost identical.
When a user in Largeville signs on, his initial program executes a CHGLIBL, which sets up the Largeville library list. If the user takes a menu option which executes WRKOUTQ SALES, he sees the spooled output in LARGEVILLE/SALES. A Smalltown user obtains a different library list at sign-on. When this user takes the same menu option, he also executes the command WRKOUTQ SALES, but sees the output queue SMALLTOWN/SALES.
When the Largeville user runs program CUSMAINT, he updates file LARGEVILLE/CUSMAST. The Smalltown user running the same program updates SMALLTOWN/CUSMAST.
Suppose our two imaginary users decide to print a list of customers. They will both select a menu option which will execute the command:
SBMJOB JOB(CUSLIST) + JOBD(SALES) + PRTTXT(*JOBD) + RQSDTA('CALL CUSLISTC')
Each user's interactive library list will find job description SALES, which has the correct library list for their location.
Once the job is submitted to batch, the library list from the job description takes over. It turns out that the customer listing program uses two data areas, LOCATION and CUSLISTOPT (customer listing option). The LOCATION data area, which contains the name of the town, is printed out in the page headers of the report. The CUSLISTOPT controls the printed format. If CUSLISTOPT is set to "2", the report is double-spaced. If it is set to anything else, the report is single-spaced. Since the people at Largeville like their report double-spaced, data area LARGEVILLE/CUSLISTOPT contains a "2", while data area SMALLTOWN/CUSLISTOPT has the value "1".
Of course the library list also determines which CUSML1 file is read and which output queue receives the report. It is all very neat and clean, much nicer than such OCL expressions as // FILE NAME-CUSML1,LABEL-CUS?L'50,1'?.
Testing
Testing is easy in our imaginary environment. We do not want to experiment with production data, so we build a test library called PROGRAMMER, by running the command:
CRTLIB LIB(PROGRAMMER) + TYPE(*TEST)
The test library can be used instead of production libraries, or it may be inserted in front of production libraries. 4 shows three possible library lists for testing.
The test library can be used instead of production libraries, or it may be inserted in front of production libraries. Figure 4 shows three possible library lists for testing.
We can use the CRTDUPOBJ or CPYF command to copy the objects we need into our test library. If we include a production library in the test library list, we only have to copy those objects that are changed. If we have any large production files, but want to test on a small number of records, we will need to copy those files, too.
We also put the test version of any programs we are modifying in the test library. If we are only modifying an RPG program, but not the CL program which calls it, we can use the production version of the CL program. It will find the test version of the RPG program when it scans the library list.
If production libraries are included in the test library list, it is a good idea to issue the STRBDG (start debug) command with the UPDPROD(*NO) option before beginning the test run. This will prevent accidentally updating production files.
When to Qualify
You should avoid qualifying object names, but there are a few situations where qualification is desirable. One is when using the temporary library, QTEMP. Consider a batch job that uses a work file. If everyone uses the same file, only one person at a time can run that job. If instead everyone has his own copy of the work file, they can all run without worrying about each other. On the System/36, you have probably done this by coding something like LABEL-WORK?WS?. On the AS/400, you can use QTEMP, since every job has its own QTEMP. In this case, it is probably a good idea to qualify names in case QTEMP is not at the top of the library list. See 5 for an example.
You should avoid qualifying object names, but there are a few situations where qualification is desirable. One is when using the temporary library, QTEMP. Consider a batch job that uses a work file. If everyone uses the same file, only one person at a time can run that job. If instead everyone has his own copy of the work file, they can all run without worrying about each other. On the System/36, you have probably done this by coding something like LABEL-WORK?WS?. On the AS/400, you can use QTEMP, since every job has its own QTEMP. In this case, it is probably a good idea to qualify names in case QTEMP is not at the top of the library list. See Figure 5 for an example.
Unqualified Objects Mean Quality Systems
Even if you do not run parallel production environments, you should still avoid qualification so you can test more easily. If testing an HLL program requires you to code a special CL program because your production CL qualifies objects, you might as well still be using a S/36.
You can say all the dirty things you want about IBM, but this is one area where they have got their act together. Let's not mess it up by qualifying objects.
Using AS/400 Library Lists in Parallel Environment
Figure 1 Objects in library GENERAL
Figure 1: Objects in Library GENERAL CUSMAINT RPG program CUSLISTC CL program CUSLISTR RPG program COMPANY data area containing company name FLDREF field reference file (physical)
Using AS/400 Library Lists in Parallel Environment
Figure 2 Objects in libraries LARGEVILLE and SMALLTOWN
Figure 2: Objects in Libraries LARGEVILLE and SMALLTOWN CUSTMAST physical file CUSTML1 logical file SALES physical file SALES job description SALES output queue LOCATION data area containing location name CUSLISTOPT data area containing option for CUSLISTR
Using AS/400 Library Lists in Parallel Environment
Figure 3 Library lists for Largeville and Smalltown offices
Figure 3: Library Lists for Largeville and Smalltown Offices QTEMP QTEMP LARGEVILLE SMALLTOWN GENERAL GENERAL QGPL QGPL QIDU QIDU
Using AS/400 Library Lists in Parallel Environment
Figure 4 Three library lists for testing
Figure 4: Three Library Lists for Testing QTEMP QTEMP QTEMP PROGRAMMER PROGRAMMER PROGRAMMER LARGEVILLE GENERAL QGPL GENERAL QGPL QIDU QGPL QIDU QRPG QIDU QRPG QRPG
Using AS/400 Library Lists in Parallel Environment
Figure 5 Program fragment using QTEMP
Figure 5: Program Fragment Using QTEMP CRTDUPOBJ OBJ(WORK) FROMLIB(SMALLTOWN) OBJTYPE(*FILE) + TOLIB(QTEMP) OVRDBF FILE(WORK) TOFILE(QTEMP/WORK) CALL PGM(PGMA) /* build work file */ CALL PGM(PGMB) /* read work file & print report */ DLTOVR FILE(WORK)
LATEST COMMENTS
MC Press Online