You pass parameters to a program by specifying them in the USING phrase of the CALL statement. For example:
CALL "program-name" USING parameter-1, ..., parameter-n
Similarly the called program specifies the parameters in the USING phrase of its Procedure Division header or its ENTRY statement. The parameters need not have the same names in the called and calling programs, but they must be in the same order. Each parameter must also be declared with the same data type and size in both the called and calling programs.
You can pass parameters in the following formats. You can pass the:
For example, the following statement passes the address of parameter-1:
CALL "program-name" USING BY CONTENT parameter-1
Each binary computational item (COMP, BINARY, COMP-4, COMP-5, and COMP-X) is passed as a COMP-5 data item. That is, it appears in machine-order as a data item and not as a pointer to that data item. The size of the COMP-5 item depends on whether the SIZE qualifier of the USING BY VALUE phrase is used. If it is, the size of the COMP-5 data item is either four or eight bytes depending on the size of the original item. If the SIZE qualifier is not specified, the default size of 4 bytes is used.
Floating point and decimal computational items (COMP-1, COMP-2, COMP-3 and PACKED DECIMAL) are copied intact to the stack without any conversion.
For example, the following statement passes a two-byte value of 5:
CALL "program-name" USING BY VALUE 5 SIZE 2.
The total size of all the parameters passed must not exceed 1020 bytes, where each BY REFERENCE and BY CONTENT parameter occupies 4 bytes.