02
Sat, Nov
2 New Articles

Going Native: AS/400 Library Management Commands

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

Techniques for working your way out of the System/36 Environment

by Ernie Malaga

Library Management

This month we will discuss the library management procedures available in SSP and how they translate into native commands. Because there is so much to cover on the general topic of library management, we won't mention those SSP procedures that combine library management with magnetic media, such as SAVELIBR.

Because S/36 libraries and AS/400 libraries are different entities, let's begin by pointing out the differences between the two systems.

On the S/36, a library is an area on disk that has a name, a directory, and is comprised of library members. The space reserved for the library has a fixed size and must be all in one piece; when this size is exceeded, SSP automatically creates a library extent somewhere else on disk, which again has a fixed size. Only one such extent can exist for each library.

There are four types of S/36 library members: source, procedure, object and subroutine. Of these, the first two can be edited directly by the user, while the last two must go through a compiler.

AS/400 libraries are somewhat different. They, too, have a name and a directory, but do not have a fixed size, and their components do not have to be in contiguous disk space. The size of the library object does not include the size of the objects contained therein. This last difference is of primary importance, and you should remember it when you read the size of a library: all you are reading is the size of the directory -- not the sum of the sizes of all the library objects.

On the AS/400, all objects, including files, are contained in libraries. This is an entirely new concept for S/36 users, who are accustomed to thinking of files as separate entries in the disk catalog, entirely unrelated to libraries.

Among the objects contained in an AS/400 library, is a type of file known as a source physical file. These files are made up of members which contain the source code for your programs, display formats, menus, procedures and so on. Remember this in the rest of the article: libraries have source physical files, which in turn have source members. It is a three-step hierarchy. In the S/36 environment, you have two source physical files: QS36SRC for "source members" and QS36PRC for "procedure members." In the native environment, it is customary, but not required, to have different source physical files for DDS (QDDSSRC), commands (QCMDSRC), CL programs (QCLSRC), RPG programs (QRPGSRC), and so on.

Condensing Libraries and Allocating Space

It may seem like an odd starting point, but let's talk about the CONDENSE procedure and the ALOCLIBR procedure. CONDENSE is used in the S/36 to reorganize all the space that has been allocated to a library, so that all the members occupy consecutive locations on disk, leaving all unused space at the "end" of the library. If a library extent exists on disk, it is merged with the library itself if there is room.

Because the AS/400 library is only a named directory of objects, the system does not really care where the components are on disk. For this reason, then, the CONDENSE procedure performs no action at all on the AS/400 S/36E; if encountered in a procedure or executed from the keyboard, the system will do nothing at all. By the same token, ALOCLIBR is equally meaningless on the AS/400 and is treated as a do-nothing procedure.

Creating, Renaming and Deleting

SSP uses the BLDLIBR procedure to create a library on disk. When you run BLDLIBR you must specify the name and the size of the library, but all other parameters are optional: directory size, preferred disk spindle, and all the diskette/tape paraphernalia that will be covered in a future installment of "Going Native".

OS/400 uses the Create Library command (CRTLIB) for the same purpose. When you create a library you are required to indicate the name of the library and nothing else. Optionally you can specify type (*PROD or *TEST -- the default is *PROD), text (a brief description of the library), public authority (which defaults to *CHANGE), and the auxiliary storage pool (ASP) number.

The distinction between *PROD (production) and *TEST (test) libraries is small, but important. Database files contained in *PROD libraries cannot be opened for update if the user is in debug mode with protection of database files. *TEST libraries, on the other hand, pay no attention to this detail.

The 50-character text is an optional parameter, but I urge you to treat it as mandatory. Try to get into the habit of entering a descriptive text for all objects you create. This text appears every time you list objects of any kind, and it will help others (and you, too) understand the purpose of the objects. Libraries are no exception.

The public authority parameter defaults to *CHANGE, which means that unless otherwise indicated, all users are allowed to add, update or delete directory entries. Unless you are in security level 30 this parameter means very little to you.

Finally, the ASP number parameter similar to the BLDFILE parameter that accepts the name of the disk spindle (A1, A2, A3, A4, or block number). The default value is 1, and unless you are creating a very specialized library and you have defined other ASPs, you should leave it that way.

RENAME changes the name of a library, and its exact equivalent is RNMOBJ (Rename Object) for object type *LIB (library). For example, RENAME MYLIB,YOURLIB can be translated into native as RNMOBJ OBJ(MYLIB) OBJTYPE(*LIB) NEWOBJ(YOURLIB).

DELETE is used to delete a library on the S/36, and it translates exactly as DLTLIB (Delete Library). However, you should know that although the S/36 DELETE procedure takes a second to run, the AS/400 DLTLIB command can take considerably longer, since it not only deletes the library directory, but all the objects contained within it. Contrast this with the S/36 DELETE, which only erases the VTOC entry for the library.

Listing a Library

The LISTLIBR procedure has three separate uses. It can be used to print the status of a library (space allocated and remaining, number of members, and so on), to print a list of members, or to list the member. Let's review each one in detail.

The closest equivalent I can think of for the library status function is the DSPOBJD command. This command gives you the size of the object (in this case, the size of the directory) among other things.

If you are interested in printing the directory of a library, you should use the DSPLIB command, which can send the output to the display or printer. If you send it to the printer, OS/400 will give you the total size of all objects in the library. Either way, you should remember that because AS/400 libraries are different, you will not see the list of source members when you run DSPLIB; it will give you the names of all the objects contained in the library, some of which are source physical files such as QS36SRC (source members) and QS36PRC (procedure members). In order to list the members, you must use the DSPFD command with TYPE(*MBRLIST).

For example, if you wanted to list all your procedure members in library MYLIB, execute the following command:

 DSPFD FILE(MYLIB/QS36PRC) + TYPE(*MBRLIST) + OUTPUT(*PRINT) 

If you change the OUTPUT parameter to OUTPUT(*), as it is by default, the list of members will be displayed instead of printed.

To list a source or procedure member, use the CPYSRCF command with TOFILE(*PRINT); that will send the listing to the printer and, unfortunately, there is no way to send it to the display instead. On the S/36 at least you could do a SYSLIST CRT before running LISTLIBR. For example, to list procedure PROCA in MYLIB, execute the following command:

 CPYSRCF FROMFILE(MYLIB/QS36PRC) + TOFILE(*PRINT) + FROMMBR(PROCA) 

To list a compiled object (such as a program), use the DMPOBJ command. For example, if you ever executed LISTLIBR to print the hexadecimal gibberish that is an actual compiled program, you can still do so (and still get hexadecimal gibberish) like this:

 DMPOBJ OBJ(MYLIB/PROGA) + OBJTYPE(*PGM) 

Creating Duplicates of Members

One of the procedures most widely used by S/36 programmers is LIBRLIBR, which creates a duplicate of a library member and optionally gives it a different name. When followed by REMOVE, the LIBRLIBR is often used to move a member from one library to another.

On the AS/400, you use the CPYSRCF command to copy source or procedure members. For example, suppose you want to write program PROG2 which is an almost exact replica of PROG1. The AS/400 can do this as follows:

 CPYSRCF FROMFILE(MYLIB/QS36SRC) + TOFILE(MYLIB/QS36SRC) + FROMMBR(PROG1) + TOMBR(PROG2) 

If the member you are copying is a compiled object, you must use the CRTDUPOBJ command instead. If PROG1 were a compiled program and you wanted to create a copy in another library, you would proceed as follows:

 CRTDUPOBJ OBJ(PROG1) + FROMLIB(MYLIB) + OBJTYPE(*PGM) + TOLIB(YOURLIB) 

Optionally you can give it a different name by adding the NEWOBJ parameter, as in:

 CRTDUPOBJ OBJ(PROG1) + FROMLIB(MYLIB) + OBJTYPE(*PGM) + TOLIB(YOURLIB) + NEWOBJ(PROG2) 

Changing the Name of a Member

SSP did not always have the CHNGEMEM procedure. I remember the days when one had to use LIBRLIBR, followed by REMOVE, in order to rename a member. When CHNGEMEM was made available (I forget with which release), I discovered that it let you change not only the name but the subtype and reference number.

Changing the name of a library member is pretty straightforward on the AS/400. For source or procedure members, you use the RNMM command; for compiled objects, the RNMOBJ command. Examples to replace a procedure and a compiled program:

 RNMM FILE(MYLIB/QS36PRC) + MBR(PROC1) + NEWMBR(PROC2) RNMOBJ OBJ(MYLIB/PROG1) + OBJTYPE(*PGM) + NEWOBJ(PROG2) 

On the AS/400 you can only change the subtype of source members. This is called "type" on the AS/400. There is no command to do it directly, but you can use SEU instead. Simply enter SEU for the source member in question and press F13 to change session defaults. Midway down the panel you will see the "source type," which you can change at will. When you exit SEU be sure to answer with a "Y" the prompt to change/create the member.

Moving a Member to Another Library

SSP does not have a means to move a member from one library to another; you must copy it first with LIBRLIBR, then use REMOVE to delete the original. OS/400 offers the MOVOBJ command to move compiled objects from one library to another. Source or procedure members still have to be copied first, then removed.

MOVOBJ is easy to use. To move PROG1 from MYLIB to YOURLIB, enter the following command:

 MOVOBJ OBJ(MYLIB/PROG1) + OBJTYPE(*PGM) + TOLIB(YOURLIB) 

Deleting Members from Libraries

Instead of using REMOVE to delete library members, you have to use the RMVM command to remove source or procedure members from the source physical file where they are located. To delete compiled objects you must use the various DLTxxx commands.

Examples: remove procedure PROC1, program PROG1, and display format member DSPFMT1 from library MYLIB:

 RMVM FILE(MYLIB/QS36PRC) + MBR(PROC1) DLTPGM PGM(MYLIB/PROG1) DLTF FILE(MYLIB/DSPFMT1) 

The last example may have given you a jolt unless you were prepared for it, right? On the AS/400, display formats are actually display files, and they are treated as such.

Stay Tuned to This Station...

Just for the fun of it, I will give you homework this time. I have explained how to manage libraries in native mode, but I have intentionally left out one item because there is no S/36 equivalent. Picture the following scenario: Your Accounts Receivable library (ARLIB) must be duplicated, ARLIB1 and ARLIB2, which will have almost identical members (the few exceptions are insignificant). How do you go about creating a duplicate of a library?

On the S/36, you run BLDLIBR to build the library followed by LIBRLIBR to copy all members from one to the other, right? The AS/400 needs only one command. If you know the command-naming scheme adopted by IBM, the answer will be obvious. If you do not know the naming scheme, pick up the CL Reference Guide (all five volumes) and dig it out!

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: