*---------*---------------*-----------------*----------------*---------------* | CODE | FACTOR 1 | FACTOR 2 | RESULT | INDICATORS | | | | | FIELD | | *---------*---------------*-----------------*----------------*---------------* | PARM | Target field | Source field | Parameter | | *---------*---------------*-----------------*----------------*---------------*
The declarative PARM operation defines the parameters that compose a parameter list (PLIST). PARM operations can appear anywhere in calculations as long as they immediately follow the PLIST or CALL operation they refer to. PARM statements must be in the order expected by the called program. One PARM statement, or as many as 255 PARM statements, can follow a PLIST or CALL.
The PARM operation can be specified anywhere within calculations, including total calculations. The control level entry (positions 7 and 8) can be blank or can contain an L1 through L9 indicator, an LR indicator, or an L0 entry to group the statement in the appropriate section of the program. Conditioning indicator entries (positions 9 through 17) are not allowed.
Factor 1 and factor 2 entries are optional. If specified, the entries must be the same type (character or numeric) as specified in the result field. A literal or named constant cannot be specified in factor 1. Factor 1 and factor 2 must be blank if the result field contains the name of a multiple-occurrence data structure.
The result field must contain the name of a field, data structure, or array that is to be the parameter. Also, the result field of a non-*ENTRY PLIST can contain an array element. The result field can be numeric or character. The result field cannot contain *IN, *INxx, *IN,xx, a label, a literal, a data-area name, a data-area data structure name, a globally initialized data structure, a data structure with initialized subfields, a data structure with a compile time array as a subfield, or a table name. In addition, an array element, a data-structure subfield name, the name of a compile-time array and the name of a program status or file information data structure (INFDS) are not allowed in the result field of PARM specified for an *ENTRY PLIST. A field name can be specified only once in an *ENTRY PLIST.
If an array is specified in the result field, the area defined for the array is passed to the called program. When a data structure with multiple occurrences is passed to the called program, all occurrences of the data structure are passed as a single field. However, if a subfield of a multiple occurrence data structure is specified in the result field, only the current occurrence of the subfield is passed to the called program.
Each parameter field has only one storage location; it is in the calling program. The address of the storage location of the result field is passed to the called program on a PARM operation. If the called program changes the value of a parameter, it changes the data at that storage location. When control returns to the calling program, the value of the parameter in the calling program (that is, the result field) has changed. Even if the called program ends in error after it changes the value of a parameter, the changed value exists in the calling program. To preserve the information passed to the called program for later use, specify in factor 2 the name of the field that contains the information you want to pass to the called program. Factor 2 is copied into the result field, and the storage address of the result field is passed to the called program.
Because the program accesses the parameter fields by address, not field name, the calling and called parameters do not have to use the same field names for fields that are passed. The attributes of the corresponding parameter fields in the calling and called programs should be the same. If they are not, undesirable results may occur.
When a CALL operation runs, the following occurs:
Figure "PLIST/PARM Operations" illustrates the PARM operation.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.