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.
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.
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:
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, 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.
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.
– See more at: http://www.mcpressonline.com/operating-systems/ibm-i-os400-i5os/as400-basics-pdms-user-defined-options.html#sthash.knMbse3j.dpuf
The options listed allow you to add, change, work with, or delete the current user option.
When creating user options, you can substitute special characters for parameters. A list and description of each follows:
&O – Object Name – Use this parameter to substitute the object name into the command you wish to call.
&M – Member Name – Use the parameter to substitute the member name into the command you wish to call. (Note, when working with members, &O and &M work the same).
&L – Library – Use the parameter to substitute the library into the command you wish to call.
&T – Type – Use the parameter to substitute the object or member type into the command you wish to call.
&A -Attribute – Use the parameter to substitute the object or member attribute into the command you wish to call.
** NOTE: When using these parameters as input parameters when calling a program defined as a user option, (as opposed to calling a command such as DSPSPLF), enclose the parameters in quotation marks.
IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.
Developerworks Connections Sunset – How to Extend RDi
Why use IBM i RDi?
How to Install IBM Access Client Solutions (ACS)
IBM i Data Obfuscation – Making Data Foggy Murky and Squinty
How to rename Fresche (BCD) Presto Library – XL_PRESTO
What is AS400 modernization?
IBM i ACS 5250 EMULATOR FONT – and other ridiculous mumbo jumbo
IBM i SQL statement to convert or compare hundred year date format
How to compare ‘100 Year Date’ to a Timestamp – aka – Weird AS400 iSeries Date formats