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)
LATEST COMMENTS
MC Press Online