Command Parameters
Most CL commands allow you to specify one or more command parameters to define what a CL command will do. A parameter is simply a value, specified along with the command, that tells the command explicitly what to do or how to do it. The CL command DSPTAP, the AS400 will not have enough information to process the command. The AS400 can have several different magnetic tape devices attached to it, and each tape device will have its own name. To display the contents of a tape, the computer needs to know specifically the name of the tape device you want to use. To direct the AS400 to use a certain tape device, you must specify, along with the DSPTAP command, the name of that device. You would need to enter the command as
DSPTAP DEV(TAP01)
where DSPTAP is the command to execute, DEV is the parameter keyword, and TAP01 is the parameter value — in this case the name of the tape device that will be used. You must separate the command and each of its parameters with one or more spaces. When you use parameter keywords like DEV, the actual parameter value must be enclosed in parentheses.
Required and Optional Parameters
Most CL commands have multiple parameters that may be specified to further define what the command should do. These parameters fall into two categories: required and optional. A required parameter is one that must be specified for the AS400 to execute a CL command. An optional parameter may be specified, but is not required for successful execution of the CL command. A few commands, such as DO and ENDDO, have no parameters.
In the earlier example above, the value for the DEV parameter keyword on the DSPTAP command must be explicitly supplied. Specifying a value for DEV indicates to the AS400 which tape device
to use for the command. The DEV parameter is an example of a required parameter.
to use for the command. The DEV parameter is an example of a required parameter.
The DSPTAP command has four other parameters for which a value may be supplied, but CL does not require that you do so. Parameters such as these are called optional parameters. CL assigns default values for optional parameters. The defaults are set to values that IBM assumes will be used most often. The default value will be used during the execution of the command unless you specifically enter a value for the optional parameter. The following example shows the DSPTAP command with the required DEV parameter and its four optional parameters. In this example, the IBM-supplied default values are shown for the optional parameters.
Think of all the lines in this example as a single command, entered on one line. The plus sign (+) is used for continuing a CL command onto more than one line, which we discuss in later topic.)
Think of all the lines in this example as a single command, entered on one line. The plus sign (+) is used for continuing a CL command onto more than one line, which we discuss in later topic.)
DSPTAP DEV(TAP01) +
LABEL(*ALL) +
SEQNBR(1) +
DATA(*LABELS) +
OUTPUT(*)
LABEL(*ALL) +
SEQNBR(1) +
DATA(*LABELS) +
OUTPUT(*)
As you can see, the last command parameter that you may specify for the DSPTAP command uses the parameter keyword OUTPUT. The default value for the parameter is *. When the parameter default of * is not changed, it tells the DSPTAP command to display the contents of the tape interactively on your workstation screen. However, if you want to send the output of the DSPTAP operation to a printed report instead of to your workstation screen, you may enter the display tape command as follows:
DSPTAP DEV(TAP01) +
OUTPUT(*PRINT)
OUTPUT(*PRINT)
This command syntax overrides the IBM-supplied default value for the OUTPUT parameter and causes a printed listing to be generated that reports on the contents of the magnetic tape.
Because specifying OUTPUT(*PRINT) is not required to execute the DSPTAP command, OUTPUT is considered an optional parameter. It is optional because the CL command can be successfully executed by
the AS400 using the IBM-supplied default value* for the parameter. You need to specify only the required parameters, and any optional parameters for which you do not want to use the IBM-supplied default values.
the AS400 using the IBM-supplied default value* for the parameter. You need to specify only the required parameters, and any optional parameters for which you do not want to use the IBM-supplied default values.
Therefore, using either of the following two command syntax forms will produce the same result:
Command syntax including the default values:
DSPTAP DEV(TAP01) +
LABEL(*ALL) +
SEQNBR(1) +
DATA(*LABELS) +
OUTPUT(*PRINT)
LABEL(*ALL) +
SEQNBR(1) +
DATA(*LABELS) +
OUTPUT(*PRINT)
or
Command syntax omitting the default values:
DSPTAP DEV(TAP01) +
OUTPUT(*PRINT)
DSPTAP DEV(TAP01) +
OUTPUT(*PRINT)
If you use the second syntax shown, the AS400 assumes you want to use the default values shown in the first syntax structure for the LABEL, SEQNBR, and DATA parameters.
Entering Parameters with Keyword Notation
In the previous examples we have presented CL commands in what is called keyword notation. Keyword notation presents all of the command parameters preceded by their corresponding keyword. For instance, in our example using the DSPTAP command,
DSPTAP DEV(TAP01) +
OUTPUT(*PRINT)
OUTPUT(*PRINT)
keywords DEV and OUTPUT are used to identify the associated parameter values, TAP01 and *PRINT. When keywords are used, the order in which the parameters are specified is not significant. The keyword itself identifies the parameter to the command. For example, the following two CL command syntax forms shown in keyword notation are equivalent:
DSPTAP DEV(TAP01) +
OUTPUT(PRINT)
OUTPUT(PRINT)
or
DSPTAP OUTPUT(*PRINT) +
DEV(TAP01)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimvgVjewDl_17tyUCW0MhR578nxIhYNxeRG9m__7kUXS61XXEGdhPy87KyKki-fUaLhB0pNwa9YPyHq1VFdet8Sjly9RvCYrb_o5OqeAtjB5laZ8uFm2PKFfzZZzSzSefyzRG0nJDmGJ8/s320/command_parameter_keyword_1.jpg)
Entering Parameters with Positional Notation
Every CL command that has parameters allows those parameters to be entered in keyword notation. You also have the option to specify many, but not all, parameters in what is called positional notation. In positional notation, keywords are not used. Instead, parameters are specified in a predetermined positional order. When you use positional notation, you must specify the parameter values in the correct order. The DSPTAP command is first shown here with keyword notation, then with positional notation.
Keyword notation:
DSPTAP DEV(TAP01)
Positional notation:
DSPTAP TAP01
Because the DEV parameter is the first command parameter, it must be specified first in positional notation. Usually, commands with only one or two parameters specified are easy to read and understand when presented in positional notation. For example, even without knowing what they do, you can easily read and
understand the following CL commands:
understand the following CL commands:
DSPTAP TAP01
DSPLIB MYLIBRARY
GOTO ENDOFPGM
CALL PROGRAM1
DSPLIB MYLIBRARY
GOTO ENDOFPGM
CALL PROGRAM1
When you specify multiple parameters in positional notation, however, readability suffers. In the following example, the CPYF (Copy File) command is presented. This is the CL command to copy data from one file to another. First the keyword notation is shown for specifying multiple parameters, then the positional notation.
Keyword notation:
CPYF FROMFILE (AFILE) +
TOFILE (BFILE) +
FROMMBR (MEMBER1) +
TOMBR (MEMBER2) +
MBROPT (*ADD)
TOFILE (BFILE) +
FROMMBR (MEMBER1) +
TOMBR (MEMBER2) +
MBROPT (*ADD)
Positional notation:
CPYF AFILE +
BFILE +
MEMBER1 +
MEMBER2 +
*ADD
CPYF AFILE +
BFILE +
MEMBER1 +
MEMBER2 +
*ADD
You can see from this example of positional notation that, unless you are familiar with the CPYF command, it is difficult to understand the meaning of the command parameters. What makes it difficult is that you cannot see which keywords are being used for which parameters. The keywords provide a frame of reference to the parameters, and in most cases, make the command easier to read.
The Order of Parameters
As we mentioned earlier, when you use positional notation to specify command parameters, you must carefully consider the order in which you specify the parameters. IBM has created the AS/400 CL command set with a predefined order in which you must specify parameters when using positional notation. The IBM publication Control Language Reference provides the documentation regarding allowable parameter values and the order in which the parameters must be specified.
As an example of the predefined order of parameters, consider again the CPYF command. The CPYF command requires that when using positional notation, the parameters be specified in the order shown below:
CPYF from-file-name +
to-file-name +
from-member-name +
to-member-name +
add-replace-option +
create-tofile-option
to-file-name +
from-member-name +
to-member-name +
add-replace-option +
create-tofile-option
1. The file to copy from (FROMFILE keyword). This is a required parameter.
2. The file to copy to (TOFILE keyword). This is a required parameter.
3. The file member to copy from (FROMMBR keyword). This parameter is optional; the default value is *FIRST.
4. The file member to copy to (TOMBR keyword). This parameter is optional; the default value is *FIRST.
5. Option to add or replace records (MBROPT keyword). This parameter is optional; the default value is *NONE.
2. The file to copy to (TOFILE keyword). This is a required parameter.
3. The file member to copy from (FROMMBR keyword). This parameter is optional; the default value is *FIRST.
4. The file member to copy to (TOMBR keyword). This parameter is optional; the default value is *FIRST.
5. Option to add or replace records (MBROPT keyword). This parameter is optional; the default value is *NONE.
Positional Keyword Limits
Every CL command limits the number of positional parameters that may be specified for the command. For example, the DSPTAP command allows you to use only one positional parameter. Therefore, if you want to specify more than one parameter value, you cannot enter the DSPTAP command in purely positional notation. You cannot enter the DSPTAP command as follows:
DSPTAP TAP01 +
*ALL +
1 +
*LABELS +
*PRINT
*ALL +
1 +
*LABELS +
Even if you could use the above format for the DSPTAP command, the resulting command would be difficult to understand. For the DSPTAP command, you can use positional notation only for the first parameter DSPTAP TAP01.
The CPYF command is one command that allows several positional parameters. This command allows up to six positional parameters. So you could enter the CPYF command as follows:
CPYF AFILE +
BFILE +
MEMBER1 +
MEMBER2 +
*ADD +
*YES
BFILE +
MEMBER1 +
MEMBER2 +
*ADD +
*YES
The CPYF command has many more parameters than are shown here, but six is the maximum number of parameters that may be specified using positional notation. This maximum is set individually for each command. You can determine the maximum number of positional parameters that can be used for a CL command by using the DSPCMD (Display Command) command to display a description of the command.
Note that even though some of the parameters for the CPYF command are optional, you may need to include an entry for them if you use positional notation. For example, if you want to specify a value for the fourth parameter (TOMBR), you will have to include a value for the third parameter (FROMMBR), even if that value is the default *FIRST. Otherwise, the fourth parameter will not be in the fourth position of the
parameter list.
parameter list.
Using *N
What if you want to use positional notation for a command, and you want to use default values for some of the parameters? You could explicitly type the default values, but there is an alternative notation you can use to specify default values when using positional notation. The value *N may be used as a place holder within
a positional notation list of parameters. For example, instead of specifying the CPYF command as:
CPYF AFILE +
BFILE +*FIRST +
*FIRST +
*REPLACE
you could use the place holder *N and specify
CPYF AFILE +
BFILE +*N +
*N +
*REPLACE
This command syntax would cause the IBM-supplied default values to be used for parameters 3 and 4 (the FROMMBR and TOMBR keywords), corresponding to the positions of the value *N. The value *N is called a predefined value. IBM-supplied predefined parameter values in CL are always preceded by an asterisk (*), helping you to easily identify them.
Mixing Keyword and Positional Notation
The predefined value *N is seldom used because it is not very easy to read or write. When you want to specify only certain parameters, keyword notation is often easier to read and write, and it has the added advantage of being somewhat self-documenting. An alternative to using the value of *N is available. It is possible to combine keyword notation and positional notation on the same command. Consider the following example:
CPYF AFILE +
BFILE +MBROPT (*REPLACE)
The positional entries of AFILE and BFILE are followed by the keyword entry of MBROPT(*REPLACE). When positional entries are mixed with keyword entries, the positional entries must be specified first, in the correct order. Keyword entries may then follow in any order. Once you begin using keyword notation in a command, you must use keyword notation for all subsequent parameters for that command. Combining positional notation with keyword notation usually produces the best compromise between readability and ease-of-entry. The use of *N should be discouraged. There is not a need to memorize command or parameter, note that the prompting facility allows you to easily determine the parameters that may be specified for any CL command and will even help you find out which command to use to perform a
task.Types of Command Parameters
CL commands allow several different types of parameters to be used. Certain parameters require that a character string be specified as the parameter value; others require decimal values. The parameter type will depend upon the context of the parameter; that is, what parameter information the command needs to function. For example, in the DSPTAP command the first parameter, DEV, requires that a device name be specified, as in DSPTAP DEV(TAP01). The third parameter, SEQNBR, requires that a numeric integer value of the tape sequence number be specified, as in DSPTAP DEV(TAP01) SEQNBR(1). Names and integer values are only two of the parameter types that may be used by a CL commandParameter Special Values
When you use the DSPTAP command, you will notice that some of the parameter values begin with an asterisk (*).DSPTAP DEV (TAP01) +
LABEL (*ALL) +
SEQNBR (1) +
DATA (*LABELS) +
OUTPUT (*PRINT)
In the command above, you can see that we specified the LABEL parameter as *ALL, the DATA parameter as *LABELS, and the OUTPUT parameter as *PRINT. Parameter values such as these that begin with an asterisk (*) are called special values. A special value allows a parameter value to be outside the normal checking rules for parameters. For example, the DSPTAP command expects to see a file label name as the value for the LABEL parameter. But the command allows you to specify the value *ALL, instead of a valid file label name, to indicate that all files on the tape are to be processed. In this case, CL reserves the meaning of the value *ALL for a specific purpose. Many command parameters allow you to choose from one or more special values that are predefined for the parameter. Note that, although the predefined value *N begins with an *, it is not considered to be a special value; it is simply a place holder when positional notation is used.
Qualified Values
Occasionally, a command parameter allows you to specify a two- or three-part parameter value, known as a qualified value or qualified name. This form of parameter value is usually used when dealing with system objects such as file names or job names. For example, if you wanted to refer to the file named CUSTOMER in library ARLIB, you could specify a single entry, ARLIB/CUSTOMER. The slash (/) is the qualifier character, separating the two parts of the value. In the following example, the DSPPFM (Display Physical File Member) command uses a qualified parameter value to specify the file name:DSPPFM FILE(ARLIB/CUSTOMER)
Parameter Value Lists
Some command parameters allow you to list more than one value. For example, the RSTOBJ (Restore Object) command allows you to specify the names of one or more (up to 300) objects that you want to restore from backup media. This command uses a simple list to identify these objects:RSTOBJ OBJ(CUSTOMER INVOICES PAYMENTS) +
SAVLIB(ARLIB) +
DEV(TAP01) +
OBJTYPE(*FILE)
In this example, we want to restore three files: CUSTOMER, INVOICES, and PAYMENTS. The elements of the list in the OBJ parameter must be separated by at least one blank.
When you use a parameter value list, you must enclose the list in parentheses, even if you use positional notation for the parameters. The following example, while it might seem correct at first glance, will not work:
RSTOBJ CUSTOMER INVOICES PAYMENTS +
ARLIB +
TAP01 +
*FILE
Because we are using positional notation, the AS400 reads the first three values as individual parameters, not as elements of the OBJ parameter list. Consequently, the AS400 will try to restore CUSTOMER to a library named INVOICES, using the tape on the non-existent device named PAYMENTS. In addition, the computer will not know how to handle what it sees as three additional positional parameter values: ARLIB, TAP01, and *FILE. The following example corrects the situation by enclosing the list parameter in parentheses:
RSTOBJ (CUSTOMER INVOICES PAYMENTS) +
ARLIB +
TAP01 +
*FILE
Complex Lists
In rare situations, you will have parameter values that include a list within another list, also called a complex list, as in the following example:RSTOBJ OBJ(*ALL) +
SAVLIB(ARLIB) +
DEV(TAP01) +
OBJTYPE(*ALL) +
FILEMBR((CUSTOMER (COMP01 COMP02)) +
(INVOICES (COMP01 COMP02)) +
(PAYMENTS (COMP01 COMP02))) +
MBROPT(*ALL)
In this example, we are restoring only the file members COMP01 and COMP02 from each of the files CUSTOMER, INVOICES, and PAYMENTS. The major list and the sublist are each enclosed in their own sets of parentheses, so it's not a trivial task to read the command as it is written.