04
Mon, Nov
5 New Articles

Using AS/400 Library Lists in Parallel Environment

General
Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

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) 
TED HOLT

Ted Holt is IT manager of Manufacturing Systems Development for Day-Brite Capri Omega, a manufacturer of lighting fixtures in Tupelo, Mississippi. He has worked in the information processing industry since 1981 and is the author or co-author of seven books. 


MC Press books written by Ted Holt available now on the MC Press Bookstore.

Complete CL: Fifth Edition Complete CL: Fifth Edition
Become a CL guru and fully leverage the abilities of your system.
List Price $79.95

Now On Sale

Complete CL: Sixth Edition Complete CL: Sixth Edition
Now fully updated! Get the master guide to Control Language programming.
List Price $79.95

Now On Sale

IBM i5/iSeries Primer IBM i5/iSeries Primer
Check out the ultimate resource and “must-have” guide for every professional working with the i5/iSeries.
List Price $99.95

Now On Sale

Qshell for iSeries Qshell for iSeries
Check out this Unix-style shell and utilities command interface for OS/400.
List Price $79.95

Now On Sale

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: