Brief: CL commands provide the basic interface to OS/400 functions. Unfortunately, commands sometimes force you to navigate through more parameters than are actually required. Learn how you can selectively control parameter prompting to make commands more efficient to use.
great feature of OS/400 CL commands is the command prompter. It's activated by keying the command name and pressing the F4 (Prompt) key or by placing a question mark (?) in front of the command name. (The latter method can also be used within a program.)
Rather than remember parameter keywords, values, and positions, a user can activate the prompter and obtain a customized data-entry panel. The panels typically contain parameter descriptions, entry fields, default values, and valid choice values. This type of prompting, referred to as command prompting, is performed at the command level.
Another (often overlooked) level of command prompting, known as selective prompting, allows you to selectively control which parameters are displayed and which ones can be modified. With selective prompting, you can control command parameter prompting to provide a more efficient and secure command interface for users.
You can use selective prompting to:
o Select the parameters for which prompting is required. o Protect parameters. o Omit parameters.
Why Use Selective Prompting?
Many commands prompt the user for more parameters than needed to perform a task. For example, let's say you frequently use the Create RPG Program (CRTRPGPGM) command. Besides the program name and source file parameters, you would like to be prompted for the ignore decimal data error (IGNDECERR) parameter. Unfortunately, each time you change IGNDECERR, you have to page through two screens of parameter prompts to get to it. Selective prompting can easily solve this problem by allowing you to present only the parameters required.
Another use of selective prompting is relevant if your operations staff does not have access to the system command line. In this case, you must provide menus, menu options, programs, and prompt screens for every task that operators need to perform.
If the user selects a menu option that activates the command prompter, selective prompting can contribute to a more secure environment.
Operators frequently perform the task of initializing tapes, using one of two common methods. With the first method, the operator keys in the Initialize Tape (INZTAP) command on a command line. He then presses F4 and fills in the necessary parameters. The disadvantage of this method is primarily a security issue. If the operator has a command line, what other commands can he enter? Which libraries and objects on the system are not adequately protected from operator error by object author-ity? In addition to the security issue, the operator may enter different parameter values or may be confused by seeing more parameters than necessary.
The second common method, often used to avoid the security issue, entails writing a program. You must create a prompt screen that displays only the information that the operator needs to see and allows only required entries to be made. The program is called from a menu option, thus eliminating the security concerns caused by allowing access to the command line. Validation performed by the program ensures that all tapes are initialized with the correct parameter values.
The disadvantage of this method is that you probably do not have time to write programs for every task performed by your operators. In this case, your operations environment will opt for the first method by default.
A Better Solution
Selective prompting of CL commands offers an alternative solution. For example, by using selective prompting for the INZTAP command, you can prompt the operator for only the parameters he needs, such as tape device (DEV) and volume identifier (VOL).
This control over parameter prompting simplifies the use of commands and requires very little programming effort. The operator can access the prompted command using a menu option. Selective prompting can be used during interactive prompting (e.g., with user-defined PDM options) or in source statements of interactive programs.
How It Works
Selective prompting requires that two special characters precede the keyword of each parameter you want to control. The first character-always a question mark (?)-simply indicates that you want to control this parameter. The second character specifies how you want the parameter controlled. It can be one of six different characters. For example, ?? before a parameter causes that parameter to be displayed and allows the operator to enter a value. The combination of ?* causes the parameter to be displayed but disables input from the operator. The ?- before the parameter prevents that parameter from being displayed; however, the value for that parameter is still passed to the command-processing program (CPP). The table in 1 briefly describes the selective prompting characters.
Selective prompting requires that two special characters precede the keyword of each parameter you want to control. The first character-always a question mark (?)-simply indicates that you want to control this parameter. The second character specifies how you want the parameter controlled. It can be one of six different characters. For example, ?? before a parameter causes that parameter to be displayed and allows the operator to enter a value. The combination of ?* causes the parameter to be displayed but disables input from the operator. The ?- before the parameter prevents that parameter from being displayed; however, the value for that parameter is still passed to the command-processing program (CPP). The table in Figure 1 briefly describes the selective prompting characters.
You can press F5 while using selective prompting to refresh the values initially shown on the display.
Some restrictions apply to selective prompting.
o No blanks should be entered between the selective prompt characters and the parameter keyword.
o Parameters must be in keyword format.
o Parameters can be specified by position only if they are not preceded by selective prompt characters.
o Selective prompting only applies at the parameter level. Now, let's look at several examples of how selective prompting can be implemented.
Example 1
Have you ever selected a menu option in error, only to find that it submitted a job immediately without any opportunity to exit or cancel without running the job?
It is a good idea to confirm all job submissions with a display that pops up before a job is submitted. The prompt screen could display a message that asks the operator, "Do you really want to do this?" But you could have a hundred jobs that require confirmation! You probably don't have time to correct them all. The following command shows how selective prompting gives the user an opportunity to cancel before submitting a job.
SBMJOB ?*CMD(CALL PGM(PGMA)) + ?*JOB(JOBA)
The two special characters (?*) preceding the CMD and JOB keywords cause the command (CALL PGM...) and the job name (JOBA) to be displayed, but prevent the user from entering a value into either of the parameters. The user can press F3 to cancel the Submit Job (SBMJOB) command. Optionally, you could allow certain parameters to be changed by the user. For example, placing ?? before the JOBQ parameter would allow the user to select the job queue each time the job was submitted.
Example 2
A second example further illustrates the usefulness of selective command prompting. If your workstation printers are powered off at IPL, the writers will not be started; or if someone shuts a printer off during the day, the writer will be canceled. Your operators, your help-desk staff, or even your programming staff may frequently receive requests from users to start writers.
The following command shows the use of selective prompting to allow any user to start a writer.
STRPRTWTR ??DEV(*N)
Two special characters (??) preceding the DEV keyword cause the device parameter to be displayed and allow the user to enter a value. No other parameters are shown. The user just needs to know the name of his printer.
Example 3
Now you'll see one more example of selective prompting. Every night, your operator uses the Save Library (SAVLIB) command to back up your system. You want to ensure that the same list of libraries is always backed up, so you do not want the operator to key in the command every night and possibly omit a critical library. But you have more than one tape drive and you want the operator to be able to select another tape drive when one is not available.
The following command shows the use of selective prompting on the SAVLIB command.
SAVLIB ?*LIB(LIBA LIBB LIBC) + ??DEV(*N)
The same set of libraries will always be saved; but if tape drive TAP01 is not available, the operator can key in the name of an-other tape drive.
Tighten and Improve Your Command Interface
The AS/400 command interface is very easy to use, mainly because the command prompter makes working with commands almost effortless. (Just think how much easier DOS would be if it had a command prompter like OS/400.)
The command prompter also facilitates management of system security. All users, including operators, can be restricted to tasks supplied as menu options. In some cases, you can avoid the overhead associated with the management of object authority. Just use a good menu-security system and restrict access to the command line by providing menu options that use selective prompting of CL commands.
Christopher Andrle is an AS/400 contract programmer with more than eight years' experience on the S/38 and AS/400.
Selective Command Prompting
Figure 1 Selective Prompting
Character Description ?? Display the parameter and allow entries. ?* Display the parameter but do not allow entries. ?/ Display the parameter but do not allow entries. Use the default value. ?< Display the parameter and allow entries. Use the default value unless a value is entered. ?- Do not display this parameter. This parameter will not be shown when F9=All parameters is pressed. ?& Display the parameter only after F9 is pressed and allow entries. Use the default value unless a value is entered. ?% Display the parameter only after F9 is pressed but do not allow entries. Use the default value.
LATEST COMMENTS
MC Press Online