QCMDSRC - Source file for command definition

By kimot, 24 December, 2022

You can create source member for command definition specifying his Type as CMD (Command).
Example of CMD source file :

*************** Beginning of data **********************************************
             CMD        PROMPT('Move Spool Files Between OutQ')                 
             PARM       KWD(OLD_LIB) TYPE(*CHAR) LEN(10) RSTD(*NO) +            
                          DFT(' ') PROMPT('From OUTQ library : ')               
             PARM       KWD(OLD_OUTQ) TYPE(*CHAR) LEN(10) RSTD(*NO) +           
                          DFT(' ') PROMPT('From OUTQ name : ')                  
             PARM       KWD(USER) TYPE(*CHAR) LEN(10) RSTD(*NO) +               
                          DFT(' ') PROMPT('Only for this User : ')              
             PARM       KWD(SPOOL_NAME) TYPE(*CHAR) LEN(10) +                   
                          RSTD(*NO) DFT(' ') PROMPT('Only this File +           
                          name : ')                                             
             PARM       KWD(USER_DATA) TYPE(*CHAR) LEN(10) RSTD(*NO) +          
                          DFT(' ') PROMPT('Only this User Data : ')             
             PARM       KWD(NEW_LIB) TYPE(*CHAR) LEN(10) RSTD(*NO) +            
                          DFT(' ') PROMPT('To OUTQ library : ')                 
             PARM       KWD(NEW_OUTQ) TYPE(*CHAR) LEN(10) RSTD(*NO) +           
                          DFT(' ') PROMPT('To OUTQ name : ')                    

and result after compilation :

                    Move Spool Files Between OutQ (MOVSPLFBQ)       
                                                                    
 Type choices, press Enter.                                         
                                                                    
 From OUTQ library :  . . . . . .   ' '           Character value   
 From OUTQ name :   . . . . . . .   ' '           Character value   
 Only for this User :   . . . . .   ' '           Character value   
 Only this File name :  . . . . .   ' '           Character value   
 Only this User Data :  . . . . .   ' '           Character value   
 To OUTQ library :  . . . . . . .   ' '           Character value   
 To OUTQ name :   . . . . . . . .   ' '           Character value                                                                       

Source file can use these definition statements :
CMD (Command Definition) -  specifies the prompt text for the command being created and allows many of the parameters. The prompt text is displayed when a user requests prompting while entering the command that is being defined.
PARM (Parameter Definition) - defines a parameter of a command being created.  A parameter is the means by which a value is passed to the command processing program.  One PARM statement must be used for each parameter that appears in the command being defined.  The order in which the PARM statements are entered into the source file determines the order in which the parameters must be specified when the command is entered in positional form and the order in which they are passed to the validity checker and the command processing program.
ELEM (Element Definition) - are used to define the elements of a mixed list parameter on a command.  A list parameter is a parameter that accepts multiple values that are passed together as consecutive values pointed to by a single parameter.  The values are preceded by a 2-byte binary value that indicates the number of elements defined for the parameter.
QUAL (Qualifier Definition) - describes one part of a qualified name.  If a name is the allowable value of a parameter or list item defined in a PARM or ELEM statement, it can be changed to a qualified name by using a QUAL statement for each qualifier used to qualify the name.
DEP (Dependent Definition) - defines a required relationship between parameters and parameter values that must be checked.  This relationship can refer to either the specific value of a parameter or parameters, or to the required presence of parameters.
PMTCTL (Prompt Control Definition) - specifies a condition that is tested to determine whether prompting is done for the parameters whose PARM statement referred to this PMTCTL statement.  The PMTCTL statement must have a statement label that matches the label referred to in the Prompt control (PMTCTL) parameter of one or more PARM statements in the command definition source.

 

CMD  - almost every parameter of this statement is included in CRTCMD command and can override it.
Only exception is parameter PROMPT and it specifies the prompt text, if any, that is included in the heading
(title) of the prompt display for the command being defined.
This is what a typical use of CMD statement in CMD source file looks like :

CMD        PROMPT('Some text displayed on the top of command screen') 

PARM - input fields definition. Typical example of this statement:

PARM       KWD(OLD_LIB) TYPE(*CHAR) LEN(10) RSTD(*NO) DFT(' ') PROMPT('From OUTQ library : ')   

most frequently used parameters :
KWD - keyword name of the parameter being defined.  Every CL command parameter has an associated keyword name.  Command parameters specified using the parameter keyword can be specified in any order.  Parameters may be specified in positional form (withouta keyword name).
TYPE - specifies the type of the value that can be specified for the parameter named in Keyword (KWD).
LEN - specifies the length of the parameter value that is passed to the command processing program (CPP).
RSTD - specifies whether the value entered for the parameter (specified in the PARM statement) is restricted to only one of the values given in the Valid values (VALUES) parameter, the Special values (SPCVAL) parameter, or the Single values (SNGVAL) parameter, or whether the  value can be any value that satisfies the requirements specified in parameters.                                           
DFT - specifies the default value that is assigned to the parameter if a value is not specified by the user.
SPCVAL  - specifies a list of up to 300 entries that define special values that can be entered on the parameter.  Each entry specifies a character string (a from-value) that can be entered even though it may not meet all validity checking requirements.  If the entered character string matches the from-value of one of the entries, and the to-value is specified, the string is replaced with the to-value and is then passed to the command processing program (CPP) without further checking.  If the to-value is omitted, the from-value is passed to the CPP.
MIN - specifies the minimum number of values that must be entered for the parameter being defined.  For a parameter that does not allow multiple like values, only zero (0) for optional and 1 for required can be specified as the minimum number of values.                  
MAX - specifies, if this PARM statement is defining a simple list parameter, the maximum number of list items that this list parameter can contain.  If a value greater than 1 is specified, the parameter is capable of accepting multiple like values (that is, a simple list).  This support is primarily intended for IBM-supplied commands.  All values entered for this parameter (at the time the command is run) must satisfy the validity checking requirements specified by the other parameter values on this PARM statement.     
ALWUNPRT - specifies whether this parameter will accept the hexadecimal character X'FF' or those hexadecimal characters in the range of  X'00' through X'3F'.  This parameter is valid only if *CHAR or *X is specified for the Type of value (TYPE) parameter.                   
EXPR - specifies whether the parameter named in the KWD parameter can accept an expression containing a character concatenation or a built-in function (%SUBSTRING or %BIN).                       
PMTCTL - specifies how prompting is be controlled for this parameter. Prompting may be controlled  by another parameter, specified by a Prompt Control (PMTCTL) statement referred to by label in this parameter, or by user request by pressing the F10 key.            
PROMPT - Specifies what prompt text is used for the parameter.  The prompt text gives a short description of the parameter which appears next to the parameter keyword and input field when the command is prompted.