20
Wed, Nov
1 New Articles

AS/400 Basics: PDM's User-defined Options

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

Brief: PDM's user-defined options can enhance your productivity by reducing the need to key frequently used commands. This article offers some practical tips on how to implement user-defined options into your programming environment.

PDM's predefined options allow you to perform various tasks against libraries, objects, and members. But did you know that you can create your own user- defined options to execute almost any command including your own? You can also optionally, have PDM fill in or prompt command parameters.

User-defined options save you from having to enter frequently used commands. For example, if you often key the Work with Spooled Files (WRKSPLF) command, you could save time by creating a user-defined option called SP. Then, when you need to access your spooled files, you can use option SP. In this article, I'll give you some tips on configuring and using PDM's user-defined options. For additional information on using PDM, see "Getting the Most Out of PDM," MC, July 1992.

Creating an Option File

PDM stores user-defined options in a physical file called an option file. The default option file, QAUOOPT in library QGPL, ships with OS/400 and includes a number of sample options to get you started. PDM allows you to specify a different option file if you want. If you use the default option file, be aware that you're sharing it with everyone else who is using it. This can cause conflicts if one person creates a user-defined option to execute a command and another person changes it to execute a different command. When the person who originally created the option tries to run it, the option no longer does what he expects.

To avoid this type of conflict, I recommend that you create your own option file and configure PDM to use it. Copy the default option file from QGPL to another library. Use the following command and specify the library of your choice in the TOLIB parameter.

 CRTDUPOBJ OBJ(QAUOOPT) + FROMLIB(QGPL) OBJTYPE(*FILE) + TOLIB(xxx) DATA(*YES) 

The DATA(*YES) parameter copies the sample options; if you want to start with an empty file, omit this parameter.

Next, start PDM and configure it to use your new option file. From PDM's main menu, press F18 (Change Defaults). On the Change Defaults screen, change the Option File parameter to point to your new file.

Creating a User-defined Option

Now you're ready to create your own user-defined options. Let's start with a simple example. Suppose you want to add a library to your library list, but you don't know the exact name of the library. You could create an option which would allow you to pick the library from a PDM list. Here's how:

1. Select option 9 from the PDM main menu to access the Work with User-Defined Options screen. To accept the currently configured file, press Enter when you're prompted for the option file. An example of the Work with User-Defined Options screen is shown in 1. An alternate method of accessing this screen is to press F16 from one of the following screens: Work with Libraries, Work with Objects, or Work with Members.

1. Select option 9 from the PDM main menu to access the Work with User-Defined Options screen. To accept the currently configured file, press Enter when you're prompted for the option file. An example of the Work with User-Defined Options screen is shown in Figure 1. An alternate method of accessing this screen is to press F16 from one of the following screens: Work with Libraries, Work with Objects, or Work with Members.

2. Press F6 to access the Create User-Defined Option screen as shown in 2. Here you're prompted for an option and a command. The option can be any one- or two-character value with the exception of 00 through 99. For this example, type AL for the option; then enter the Add Library List Entry (ADDLIBLE) command.

2. Press F6 to access the Create User-Defined Option screen as shown in Figure 2. Here you're prompted for an option and a command. The option can be any one- or two-character value with the exception of 00 through 99. For this example, type AL for the option; then enter the Add Library List Entry (ADDLIBLE) command.

ADDLIBLE LIB(&N)

3. Press Enter to create the option, then F3 to exit back to the main PDM screen.

To use the new option, select option 1 to Work with Libraries and type *ALL when prompted for a library name. PDM will present you with a list of libraries. When you select a library with option AL, PDM adds it to the top of your library list.

Substitution Variables

In the previous example, &N was specified in the LIB parameter of the ADDLIBLE command. In this context, &N is known as a substitution variable. PDM replaces this variable with the name of the item in the list. This example substitutes a library name, but it could be an object name or member name depending on which PDM screen you're using. &N is one of the 20 substitution variables provided by PDM, as shown in 3.

In the previous example, &N was specified in the LIB parameter of the ADDLIBLE command. In this context, &N is known as a substitution variable. PDM replaces this variable with the name of the item in the list. This example substitutes a library name, but it could be an object name or member name depending on which PDM screen you're using. &N is one of the 20 substitution variables provided by PDM, as shown in Figure 3.

Some of PDM's substitution variables are replaced with different values depending on what PDM screen you're using. For instance, PDM replaces &A with the object attribute if you're working with objects; otherwise, PDM replaces &A with the value *NULL.

Let's look at another example using substitution variables. Suppose you're working with members in PDM and you want to create a Query Management Query (QMQRY). First, you create a source member containing an SQL statement. Then, compile it with the Create Query Management Query (CRTQMQRY) command. Since you created the source member with a member type of QMQRY, you would think that option 14 (compile) would do the job, but it doesn't. A user-defined option can easily solve this problem. Create an option, call it CQ, and assign this to it.

 CRTQMQRY QMQRY(&L/&N) + SRCFILE(&L/&F) 

This example uses three substitution variables: &L is replaced with the name of the library; &F, with the source file name; and &N, with the name of the source member. Now, when you want to compile a QMQRY source member, you can use option CQ.

Once you have created the QMQRY object, you'll want to run it using the Start Query Management Query (STR-QMQRY) command. Again, you might think that you could use option 16 (run) on the Work with Objects screen against a QMQRY object, but that doesn't work either. To solve this problem, create another user-defined option, call it SQ, and assign it the following command:

STRQMQRY QMQRY(&L/&N)

PDM replaces &L and &N with the library and name of the QMQRY object. To run the QMQRY, use the SQ option. This works on either the Work with Objects or Work with Members screen.

(For more information, see "Query Management Magic," MC, November 1994).

Selective Command Prompting

Another technique you can take advantage of in user-defined options is selective command prompting. (See "Selective Command Prompting," MC, September 1994). This technique allows you to selectively control which parameters are displayed and which can be modified when you execute a user-defined option.

You can activate selective prompting by placing two special characters in front of each keyword parameter you want to control (see 4). For example, you could create a user-defined option called SJ which executes the Submit Job (SBMJOB) command. In this case, you might want to force PDM to prompt the command (CMD) parameter so that it can be modified if necessary. You could assign the following command to the SJ user-defined option:

You can activate selective prompting by placing two special characters in front of each keyword parameter you want to control (see Figure 4). For example, you could create a user-defined option called SJ which executes the Submit Job (SBMJOB) command. In this case, you might want to force PDM to prompt the command (CMD) parameter so that it can be modified if necessary. You could assign the following command to the SJ user-defined option:

 SBMJOB ??CMD(CALL PGM(&N)) + ?*JOB(&N) ?*JOBD(&J) 

The two question marks (??) in front of the CMD keyword cause PDM to prompt the CMD parameter so that it can be modified. The question mark and asterisk (?*) combination displays the JOB and JOBD parameters but does not allow them to be changed. When you execute the SJ option, you only see three parameters and only the first one is input-capable. This technique gives you more flexibility in processing your user-defined options.

A Few Favorites

I've demonstrated some basic techniques to create user-defined options. In addition to the examples I've shown and the ones that come with OS/400, 5 shows a few more that you might find useful.

I've demonstrated some basic techniques to create user-defined options. In addition to the examples I've shown and the ones that come with OS/400, Figure 5 shows a few more that you might find useful.

o Option PC can assist you when you need to download a file from your AS/400.

It uses the Copy to PC Document (CPYTOPCD) command to copy records from a file

member to a document in a folder. From there, you can use the PC Support

(Client Access) shared-folder facility to access the file.

o Options SD, AB, and ED are useful for debugging programs. Option SD starts

the system debugging facility for a selected program. Option AB adds

breakpoints to display program variables. Option ED ends the system debugger.

o Option OP optimizes a program using the Change Program (CHGPGM) command,

thereby allowing a program to make more efficient use of system resources.

o Option CP compresses an object with the Compress Object (CPROBJ) command.

Compressing an object not only saves disk space but also allows you to transfer

it faster through a SNADS network.

o Option SN executes a Send Network File (SNDNETF) command to send a file

through a SNADS network.

o Option RQ displays the records in a file using the Run Query (RUNQRY)

command.

o Option CR compiles an RPG program in batch and produces an indented listing.

These are just a few user-defined options that I find useful; I'm sure you can

come up with many more on your own.

Customized Time-savers

PDM's user-defined options can save you time by reducing the need to key the commands you use most often. Start with the default set of options that IBM ships with OS/400. Supplement them with the ones you find useful from this article. Then add your own a little at a time as you find the need. Before you know it, you'll have a rich set of user-defined options to give you a more productive working environment.

Robin Klima is a senior technical editor for Midrange Computing.

REFERENCE

Programming Development Manager Guide and Reference (SC09-1339, CD-ROM

QBKA0602).


AS/400 Basics: PDM's User-defined Options

Figure 1 Work with User-Defined Options

 UNABLE TO REPRODUCE GRAPHICS 
AS/400 Basics: PDM's User-defined Options

Figure 2 Create User-Defined Option Screen

 UNABLE TO REPRODUCE GRAPHICS 
AS/400 Basics: PDM's User-defined Options

Figure 3 Substitution Variables for User-defined Options

 Value Meaning Description &A Object attribute If you're working with objects, &A is replaced by the object attribute from the list. Otherwise, &A is replaced by *NULL. &B List type If you're working with a library list (*LIBL,*USRLIBL), &B is replaced by X. If you're working with a list of libraries (*ALL, *ALLUSR), &B is replaced by L. If you're working with a list of objects, &B is replaced by O. If you're working with a list of members, &B is replaced by M. &C Option &C is replaced by the user-defined option code. &D Member change date If you're working with members, &D is replaced by the date the member was last changed. Otherwise, &D is replaced by *NULL. &E Run in batch &E is replaced by *YES if Y is specified in the Run in batch prompt on the Change Defaults display and *NO if N is specified. &F File name If you're working with members, &F is replaced by the name of the file that contains these members. Otherwise, &F is replaced by *NULL. &G Job description &G is replaced by the job description library value from the Change Defaults display. &H Job description &H is replaced by the job description value from library the Change Defaults display. &J Job description &J is replaced by the job description value from name the Change Defaults display in the format library/job description. &L Library name If you're working with libraries, &L is replaced by QSYS. If you're working with objects or members, &L is replaced by the name of the library that contains the objects or members. &N Item name &N is replaced by the name of the item in the list beside which the option was typed. &O Object library &O is replaced by the object library from the Change Defaults display. &P Compile in batch &P is replaced by *YES if Y is specified in the Compile in batch prompt on the Change Defaults display and *NO if N is specified. &R Replace object &R is replaced by *YES if Y is specified in the Replace object prompt on the Change Defaults display and *NO if N is specified. &S Item type without '*' If you're working with libraries, &S is replaced by LIB. If you're working with objects, &S is replaced by the object type without the asterisk ('*'). If you're working with members, &S is replaced by the member type as is. &T Item type with '*' If you're working with libraries, &T is replaced by *LIB. If you're working with objects or members, &T is replaced by the object or member type as is. &U User-Defined Option &U is replaced by the user-defined option file File name from the Change Defaults display. &V User-Defined Option &V is replaced by the user-defined option library Library name from the Change Defaults display. &W User-Defined Option &W is replaced by the user-defined option file File Member member name from the Change Defaults display. &X Item text &X is replaced by the text (in single quotation marks) of the item beside which the option was typed. 
AS/400 Basics: PDM's User-defined Options

Figure 4 Selective Prompting Characters

 Characters Description ?? Displays the parameter and allows input. ?* Displays the parameter, but does not allow input. ?< Displays the parameter and allows input. Uses the default value unless a value is entered. ?- Does not display the parameter even when F9 (All parameters) is pressed. ?& Displays the parameter only after F9 is pressed and allows input. ?% Displays the parameter only after F9 is pressed and does not allow input. 
AS/400 Basics: PDM's User-defined Options

Figure 5 Useful User-defined Options

 Option Command PC CPYTOPCD ?*FROMFILE(&N/&F) ??TOFLR() ?*FROMMBR(&N) ??TODOC(&N) SD STRDBG PGM(&N) AB ADDBKP ??STMT() ??PGMVAR() ED ENDDBG OP CHGPGM PGM(&L/&N) OPTIMIZE(*YES) CP CPROBJ OBJ(&L/&N) OBJTYPE(&T) SN SNDNETF ?*FILE(&L/&F) ??TOUSRID() ?*MBR(&N) RQ RUNQRY QRY(*NONE) QRYFILE((&L/&N)) CR SBMJOB CMD(CRTRPGPGM PGM(&L/&N) SRCFILE(&L/&F) INDENT(': ')) + JOB(&N) JOBD(&J) 
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: