The parameter list is a mechanism for passing information to a program at execution time that can be used to make a program more versatile. Parameters are implemented by the operating system and are supported by all of the programming languages. This document covers the COBOL implementation, but all others are analogous. Some references to the ESA/390 general purpose registers (R0-R15) will be made.

There are two types of parameter lists that are covered in this document, positional and keyword. A positional parameter list is one where the data values are assigned specific meanings based on their order within the parameter list. The PM utility program YWEXCBA, which is used in the HQ/PM batch cycle, implements positional parameters. A keyword parameter list is one where the meaning of the parameter is based on a keyword prefix usually delimited from the parameter’s value by an equal sign (=). It is sometimes convenient to code keyword parameters using parentheses to delimit the keyword parameter’s value, such as when the parameter might contain blanks or punctuation characters. MCIT symbolic replacement utility program, DR0069CP (see tech newsletter #10), implements symbolics as keyword parameters. A big advantage of using keyword parameters is that the parameters may be presented in any order. Of course there is more coding required to support keyword parameters than positional parameters.

A parameter list is passed to a program at execution time by using the ‘PARM=’ subparameter of the ‘EXEC’ JCL statement. The parameter list is simply a character string of up to 100 bytes of data whose address is passed to the EXECed program via general register 1 (R1). R1 is an address that points to a half word (2 bytes) binary field that contains the length of the parameter list exclusive of the length field itself. The actual parameter list starts at the end of the length field. The parameter list is accessible in a COBOL program through the LINKAGE SECTION and the PROCEDURE DIVISION USING … statements.

Parameter passing examples:

Positional: //STEP01 EXEC PGM=YWEXCBA,PARM=’SHAD,APM’

Keyword: //STEP01 EXEC PGM=DR0069BC,

// PARM=’MEM=&MEM,SIZE=&SIZE,DATA=&DATA’

//STEP02 EXEC PGM=IEFBR14,

// PARM=’TYPE(TEST),DATE(08-19-1999)

 

 

 

 

 

 

COBOL code examples:

WORKING-STORAGE SECTION.

01

LINKAGE SECTION.

    1. PARAMETERS.

02 PARM-LENGTH PIC S9(04) COMP.

02 PARM-CHAR PIC X(01)

OCCURS 100 TIMES.

.

.

.

PROCEDURE DIVISION USING PARAMETERS.

IF PARM-LENGTH = ZERO

DISPLAY ‘REQUIRED PARAMETER(S) MISSING.’

DISPLAY ‘PROCESSING TERMINATED.’

MOVE 16 TO RETURN-CODE

GOBACK

END-IF.

* POSITIONAL PARAMETERS