August 27

0 comments

PDM user defined options

By NickLitten

August 27, 2013

user, defined, options, PDM

Boost your productivity with PDM User Defined Options

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.

Creating an Option File

Pdm user defined options

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.

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.

  • 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.
  • 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.
  • Option OP optimizes a program using the Change Program (CHGPGM) command, thereby allowing a program to make more efficient use of system resources.
  • 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.
  • Option SN executes a Send Network File (SNDNETF) command to send a file through a SNADS network.
  • Option RQ displays the records in a file using the Run Query (RUNQRY) command.
  • 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.

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.

https://www.nicklitten.com/course/ibm-i-pdm-101-ep1-what-is-the-programming-development-manager/
{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Join the IBM i Community for FREE Presentations, Lessons, Hints and Tips

>