When using PDM have you ever wanted to have your option do something different from the default way of doing it. For example if you want to use your own values in certain parameters for creating a RPGLE program. You can do so using without changing the command by using PDM’s user defined options.
IBM announced when IBM i
7.1 6.1 was launched that PDM and SEU would no longer be updated, they are still very popular (for more details see here). Over the years I have found that many developers do not use the options within PDM. In this post I am going to describe how to change the defaults for your PDM and how to configure user-defined options.
A large number of PDM users access PDM by typing: STRPDM and pressing enter, and then taking the option from menu to work with libraries, objects, or members. You can skip the menu by using one of the following commands:
- WRKLIBPBM - to work with libraries. For example if I want to view all the members that start with the letter A I type WRKLIBPDM A* and press Enter.
- WRKOBJPDM - to work with the objects within a library. For example if I want to display all of the objects in my library, MYLIB, I type WRKOBJPDM MYLIB and press Enter.
- WRKMBRPDM - to work with members within a source file. This is the PDM command I use the most. I have all my source members in one source file in my library in a source file called DEVSRC, you can read why I do this in Source files one or many. Therefore, if want to see all of the members I have that start with OTD, regardless of source type, I type WRKMBRPDM DEVSRC OTD* and press Enter, this assumes I have the library MYLIB in my library list.
All of these commands can be prompted, by using the F4 key, to use the other parameters I have not mentioned above.
I have found that the easiest way to work with your PDM defaults is to use one of the commands I have mentioned. For example if I want to work with mine I can: WRKOBJPDM and press Enter. Regardless of which objects are displayed I press F18 to view and change my defaults. Below are the standard defaults:
Change Defaults Type choices, press Enter. Object library . . . . . . . *SRCLIB Name, *CURLIB, *SRCLIB Replace object . . . . . . . N Y=Yes, N=No Compile in batch . . . . . . Y Y=Yes, N=No Run in batch . . . . . . . . N Y=Yes, N=No Save session defaults . . . Y Y=Yes, N=No Save/Restore option . . . . 1 1=Single, 2=All Job description . . . . . . QBATCH Name, *USRPRF, F4 for Library . . . . . . . . . *LIBL Name, *CURLIB, *LIBL Change type and text . . . . Y Y=Yes, N=No Option file . . . . . . . . QAUOOPT Name Library . . . . . . . . . QGPL Name, *CURLIB, *LIBL Member . . . . . . . . . . . QAUOOPT Name Full screen mode . . . . . . N Y=Yes, N=No More...
Options on the second screen:
Log option commands . . . . . N Y=Yes, N=No Exit lists on ENTER . . . . N Y=Yes, N=No Display informational messages N Y=Yes, N=No
Feel free to change and “play” with these defaults until you find what you are happy with. Below are my defaults compared to the standard ones.
|Default||Standard||My preference||Object library||*SRCLIB||*SRCLIB|
|Compile in batch||Y||N – As I work on a development server compiling interactively does not adversely affect business processing|
|Run in batch||N||N|
|Save session defaults||Y||Y|
|Job description||QBATCH||MYJOBD – I use my own job description|
|Job description library||*LIBL||MYLIB – My job description is in my library|
|Change type and text||Y||N – I have changed this to prevent me from accidentally changing the object type or text. I use F13 to change the type and text|
|Option file||QAUOOPT||PDMOPTIONS – I have my own copy of the file. I explain later in this post why|
|Option file library||QGPL||MYLIB – I have the PDM option file in my own library|
|Option file member||QAUOOPT||PDMOPTIONS - I will explain later|
|Full screen mode||N||Y – I prefer not to see what the options and function keys are as I am familiar with them. This also increases the number of member visible|
|Log option commands||N||N|
|Exit list on ENTER||Y||N - I do not want to exit PDM when I press Enter|
|Display informational messages||N||N|
For an explanation of what each parameter does see here.
User defined options
Before you start making your own PDM option I strongly recommend that you make your own copy of the default PDM options file into your library. Then any options you make you will be able to use and they will not be changed or deleted by others.
As I have shown above the PDM option file is called QAUOOPT and is in the library QGPL. If I wanted to make my own copy of the file in my library I would execute the following commands:
CRTDUPOBJ OBJ(QAUOOPT) FROMLIB(QGPL) OBJTYPE(*FILE) TOLIB(MYLIB) NEWOBJ(PDMOPTIONS) CST(*NO) TRG(*NO) RNMM FILE(MYLIB/PDMOPTIONS) MBR(QAUOOPT) NEWMBR(PDMOPTIONS)
You do not have to rename the member, I just do as I prefer to.
Now change your PDM defaults to use the option file you just created. Type WRKMBRPDM and press Enter. Press F18 to go to the ‘Option file’ parameters and change them to be the name of the file, the library the file is in, and the member name you have just created. When you press Enter you have updated your PDM defaults, but only from this point forward. If you have PDM active on another session it will still use the old settings. To update them just go to each of your sessions exit PDM and then start it again.
To view the user defined options at any PDM screen (WRKLIBPDM, WRKOBJPDM, WRKMBRPDM) and press F16.
Work with User-Defined Options DEV400 File . . . . . . . : PDMOPTIONS Member . . . . . . : PDMOPTIONS Library . . . . : MYLIB Position to . . . : Type options, press Enter. 2=Change 3=Copy 4=Delete 5=Display Opt Option Command AB STRCODECMD CMD('CODEBRWS "&ZP/&ZL/&ZT/&ZN"') AD STRCODECMD CMD('CODEDSU "&ZP/&ZL/&ZT/&ZN"') AE STRCODECMD CMD('CODEEDIT "&ZP/&ZL/&ZT/&ZN"') C CALL &O/&N BC CRTBNDCL PGM(&O) DBGVIEW(*SOURCE) BG STRDBG PGM(&O/&N) UPDPROD(*YES) BR CRTBNDRPG OPTION(*NODEBUGIO *SRCSTMT) DBGVIEW(*SOURCE) CB STRCODECMD CMD('CODEBRWS "<>&L/&F(&N)"') CC CHGCURLIB CURLIB(&L) More... Command ===> F3=Exit F4=Prompt F5=Refresh F6=Create F9=Retrieve F10=Command entry F24=More keys
The options you see are likely to be different to the ones displayed above.
What you will see are the options that others created in the QAUOOPT file. You have two choices:
- Clear the file and start afresh with your own options.
- Keep the existing options and add your own.
In the Command column you will notice that some of the parameters for the commands contain variables that start with the & symbol. These are variables that can be passed to the command. There are many, most of which I have never found a reason to use. The ones I use are:
|&F||If you are working with members: name of file you are currently in.
If you are working with objects or libraries: *NULL.
|&L||If you are working with members or objects: Name of the library you are currently in.
If you are working with libraries: QSYS.
|&N||Name of the item selected.|
|&T||If you are working with members or objects: Type of the object or member.
If you are working with libraries: *LIB.
For a list of all these variables refer to the PDM manual I have provided a link to at the bottom of this post.
In this example let’s create an option to perform the CALL command.
To create a new user defined option press F6.
Create User-Defined Option Type option and command, press Enter. Option . . . . . . . . . Option to create Command . . . . . . . . .
The option codes 00 – 99 are reserved, but any other single or double digit code is permissible. I am going to use CA.
I enter CALL in the Command parameter and press F4 to prompt it. In the Program parameter I put &N and in the Library parameter I put &L, then I press Enter.
Create User-Defined Option Type option and command, press Enter. Option . . . . . . . . . CA Option to create Command . . . . . . . . . CALL PGM(&L/&N)
What if I want the command to be prompted before it is run? I add a question mark before the command:
Create User-Defined Option Type option and command, press Enter. Option . . . . . . . . . CA Option to create Command . . . . . . . . . ? CALL PGM(&L/&N)
By all means this is a very simple example, but I am sure you get the idea for using this with more complex commands. For example:
Option Command R1 ? RUNQRY QRY(*NONE) QRYFILE((&L/&F &N)) SJ ? SBMJOB CMD(CALL PGM(&L/&N)) JOB(&N) HOLD(*NO) SP WRKSPLF SQ STRSQL SV ? SAVRSTOBJ OBJ(&N) LIB(&L) RMTLOCNAME(PROD400) OBJTYPE(&T) S3 ? STRSDA OPTION(3) SRCFILE(&L/&F) SRCMBR(&N) OBJLIB(&L) TSTFILE(*LIBL/&N) VQ ? RTVQMQRY QMQRY(&L/&N) SRCFILE(MYLIB/DEVSRC) ALWQRYDFN(*YES)
PDM versus RDp/RDi
At the Technical Release 7 (TR7) presentation I attended when asked by the presenter to raise your hand if you are using PDM and not RDi, the overwhelming majority of attendees raised their hands.
Over the past few weeks I have been running a poll on Facebook as to which editing tool IBM i developers use. The results are:
You can learn more about these from the IBM web site:
This article was written for IBM i 7.1, and it should work with earlier releases too.