ILE COBOL Language Reference

USING Phrase

Included in the CALL statement when parameters need to be passed to the called subprogram. If this is also written in COBOL, it must contain a USING phrase in its Procedure Division header. Procedure Division header of the called subprogram. The number of operands in both USING phrases must be identical. For CALL statements with a LINKAGE TYPE of program the maximum number of operands is 255, and for LINKAGE TYPE of procedure the maximum number of operands is 400.

The sequence of identifiers in the USING phrase of the CALL statement and in the corresponding USING phrase in the called subprogram's Procedure Division header determines the correspondence between the identifiers used by the calling and called programs. This correspondence is by position, rather than by name. For more information about the USING phrase, see The USING Phrase.

The attributes of the data passed depend on the requirements of the called subprogram. If a called program requires several parameters, you must specify the identity of each parameter, rather than a group item that consists of the parameters.

+-------------------------------IBM Extension--------------------------------+

Some procedures (for example, the ILE CEEDATE and CEEDAYS APIs) require that the operational descriptor of one or more parameters is made available. This requirement must be satisfied by including, in the SPECIAL-NAMES paragraph, a LINKAGE TYPE clause for the procedure with a USING phrase that specifies the appropriate parameter. In addition, any such parameter must be defined as an elementary data item with a USAGE of DISPLAY or DISPLAY-1, and it may not be reference modified.

+----------------------------End of IBM Extension----------------------------+

The values of the parameters referenced in the USING phrase of the CALL statement are made available to the called subprogram at the time the CALL statement is executed.

USING Phrase Example

Calling Program Description (PGMA) Called Program Description (PGMB)
WORKING-STORAGE
SECTION.
01 ARG-LIST.
   05 PARTCODE PIC A.
   05 PARTNO PIC X(4).
   05 U-SALES PIC 9(5).
   .
   .
   .
PROCEDURE DIVISION.
   .
   .
   .
      CALL PGMB
       USING ARG-LIST.
LINKAGE SECTION.
01 PARAM-LIST.
    10 PART-ID PIC X(5).
    10 SALES PIC 9(5).
   .
   .
   .
PROCEDURE DIVISION USING
PARAM-LIST.
Note:
In the calling program, the code for parts (PARTCODE) and the part number (PARTNO) are referred to separately. In the called subprogram, the code for parts and the part number are combined into one data item (PART-ID); therefore in the called subprogram, a reference to PART-ID is the only valid reference to them.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]