I have a number of CL programs I have written for myself to "speed up" things I do on a regular basis. For example, I work in an environment with multiple PowerSystems servers each with one or more IBM i partitions. If I need to move object from one to another I could type in the series of commands I use one at a time, find the parameters I need to change, enter the value I want into the parameter, and then press Enter. Being someone who likes to KISS (Keep It Simple Simon) I have developed programs were I use selective prompting on the commands to keep it simple.
What is selective prompting? It is when in a CL program a command is displayed prompted, and parameters can be seen and changed. I can have all the parameters displayed and changeable, or only some displayed and only some of those changeable. The other parameters remain hidden and unchangeable. It allows me to only display the parameters I want to, the ones I need to change. The screen shot below shows what I mean:
Save Object (SAVOBJ) Type choices, press Enter. Objects . . . . . . . . . . . . __________ Name, generic*, *ALL + for more values __________ Library . . . . . . . . . . . . __________ Name, generic*, *USRSPC + for more values __________ Device . . . . . . . . . . . . . > *SAVF Name, *SAVF, *MEDDFN Object types . . . . . . . . . . *ALL___ *ALL, *ALRTBL, *BNDDIR... + for more values _______ Save file . . . . . . . . . . . > SAVEFILE Name Library . . . . . . . . . . . > QTEMP Name, *LIBL, *CURLIB Additional Parameters Target release . . . . . . . . . > *CURRENT *CURRENT, *PRV, V5R4M0... Data compression . . . . . . . . > *HIGH__ *DEV, *NO, *YES, *LOW... |
As you can see there are only five parameters I can change. The Save File name and library is shown but cannot be changed. All of the other parameters, including the "Additional parameters" that can normally be viewed by pressing F10, are not available to be seen or changed. When using this all I have to do is change the few parameters and press Enter, which makes this simple and fast.
What does the command look like in the CL program?
SAVOBJ ??OBJ() ??LIB() ?*DEV(*SAVF) + ?<OBJTYPE() ?*SAVF(QTEMP/SAVEFILE) + ??TGTRLS(*CURRENT) ??DTACPR(*HIGH) |
The first thing I am sure you have noticed that all of the parameters have a question mark ( ? ) followed by another character before the parameter keyword. These are the selective prompt codes. The valid selective prompt codes are:
Character | Description |
?? | The parameter is displayed and input-capable. |
?* | The parameter is displayed but is not input-capable. |
?< | The parameter is displayed and is input-capable. The command default is sent to the CPP (Command Processing Program) unless the value displayed on the parameter is changed. |
?– | The parameter is not displayed. The specified value is passed to the CPP. |
?& | The parameter is not displayed until "F9=All parameters" is pressed. When displayed, it is input-capable. |
?% | The parameter is not displayed until "F9=All parameters" is pressed. When displayed, it is not input-capable. |
For the SAVOBJ command I showed this means that:
Can be changed ?? |
Cannot be changed ?* |
Uses default, unless changed ?< |
OBJ LIB TGTRLS DTACRP |
DEV SAVF |
OBJTYPE |
I have found if you want to see parameters that are in the "Additional parameters", those shown the second screen and beyond, on your first screen then you need to make them changeable with ??. Otherwise you will have to press F10 to see them.
As I mentioned this is part of a CL program I use to transfer objects from one IBM i to another. The program in full looks like:
01 PGM 02 MONMSG MSGID(CPF6801) EXEC(GOTO CMDLBL(END)) 03 CLRSAVF FILE(QTEMP/SAVEFILE) 04 MONMSG MSGID(CPF9812) + EXEC(CRTSAVF FILE(QTEMP/SAVEFILE)) 05 SAVOBJ ??OBJ() ??LIB() ?*DEV(*SAVF) + ?<OBJTYPE() ?*SAVF(QTEMP/SAVEFILE) + ??TGTRLS(*CURRENT) ??DTACPR(*HIGH) 06 SAVRSTOBJ ?*OBJ(SAVEFILE) ?*LIB(QTEMP) + ??RMTLOCNAME(OTHER_IBM_I) ?*OBJTYPE(*FILE) + ??RSTLIB(MYLIB) 07 END: ENDPGM |
The Monitor Message command, MONMSG on line 2, checks for CPF6801. This message occurs if I press F3 or F12 at one of the prompted commands. As this has been placed at the top of the program, after any variable definitions, this will apply to all other commands in the program. I would have preferred to have RETURN executed if the error occurred, but it is not supported in this place. Therefore, I use a GOTO which goes to the last line of the program.
On lines 3 and 4 I am either clearing an existing save file or creating a new one.
With Save Object command, SAVOBJ on line 5, I am leaving the object (OBJ) and library (LIB) parameters blank as I will fill those in when I run the program. The object type (OBJTYPE) will display the default value, which is *ALL, and allow me to change if I want. The save file name and library (SAVF) is displayed, but I cannot change it. I have to use ?? with target release (TGTRLS) so it will be displayed without me having to press F10 for the additional parameters. I have the data compression (DTACPR) set for high. I am not going to describe what this means here, I am going to refer you to Multiple levels of data compression in save commands.
The next command, line 6, is the Save and Restore Object command, SAVRESTOBJ.
Save Restore Object (SAVRSTOBJ) Type choices, press Enter. Objects . . . . . . . . . . . . > SAVEFILE Name, generic*, *ALL Saved library . . . . . . . . . > QTEMP Name, generic*, *ALLUSR Remote location name . . . . . . > OTHER_IBM_I______ Object types . . . . . . . . . . > *FILE *ALL, *ALRTBL, *BNDDIR... Additional Parameters Restore to library . . . . . . . > MYLIB_____ Name, *LIB |
The name of the object to be saved, its library, and its object type (OBJ, LIB, OBJTYPE) are display only as they will always be SAVEFILE, QTEMP, and *FILE. The remote location name (RMTLOCNAME) does need to be changeable so I can enter the name of which IBM i I want the save file to be restored to. The restore library (RSTLIB) can also be changed as I have to give a library into which the save file will be restored, as the save file cannot be restored into QTEMP on the remote IBM i.
I hope this simple example of selective prompts can be used to guide you to make your programs containing them, making the common and mundane tasks we all perform easier.
;p>
You can learn more about this from IBM's website here.
;p>
This article was written for IBM i 7.2, and should work for earlier releases too.
Good info, IBM has great flexibility!
ReplyDeleteAnother great tool for i5 developers, thanks Simon.
ReplyDeleteWorking smarter not harder
ReplyDeleteI also use parameters validations and help screens. But, I am started my career on system 38. So, I am old school. Now today with modern gui new developer are not aware of all that is still available.
ReplyDeleteMore features then I remembered. Thanks for sharing!
ReplyDeleteBeen using it for years. I love it.
ReplyDeleteGood one. I don't use this type of prompting but I can see now why I should. Thanks!
ReplyDeleteWow I learned something new! I can't think of anything immediately, but I'm sure this will come in very handy somewhere along the road. Thanks for another useful tip.
ReplyDeleteVery useful, when "wrapping" commands for special purposes. Use some of these regularly. Didn't know all of them yet. Thx.
ReplyDeleteSimon, another great teaching moment from you.. I like this
ReplyDelete“What is selective prompting? It is when in a CL program a command is displayed prompted, and parameters can be seen and changed.”
Thanks for sharing.
That's super cool. Thanks Simon!
ReplyDeleteBeen using it for years. Very useful and quick.
ReplyDeleteExcellent info
ReplyDeleteThis is awesome..never really used it..
ReplyDeleteI often do the prompting with Qchkcmd. If this returns a valid command string it can be run with Qcmdexc. Also useful for logging.
ReplyDelete