COBOL/400 Language Help

Format 1 (CALL ON OVERFLOW)

Description
The program containing the CALL statement is the calling program; the program identified in the CALL statement is the called subprogram.
Format 1 (CALL ON OVERFLOW)
 
->->--CALL--*--identifier-1--*---------------------------------------->
          *--literal-1-----*
 
->--*-------------------------------------------------------------*-->
   +        *---------------------------------------------------*+
   +        +                       *--------------------------*++
   +        V                       V                          +++
   *-USING--*-*-------------------*-*-------------*identifier-2***
            + *-*----*-REFERENCE--* *-ADDRESS OF--*            ++
            +   *-BY-*              *-file-name-1--------------*+
            +                                                   +
            +               *----------------------------------*+
            +               V                                  ++
            **----*-CONTENT-*--*----------*--------identifier-2**
             *-BY-*         +  *ADDRESS OF*                    +
                            +  *LENGTH OF-*                    +
                            *--*-literal-2---*-----------------*
                               *-file-name-1-*
 
->--*--------------------------------------*------------------------->
   *-*--*OVERFLOW imperative-statement-1--*
     *ON*
 
->--*------------*---------------------------------------------------><-
   *--END-CALL--*

identifier-1

Identifier-1 must be an alphanumeric data item. Its contents must follow the rules for formation of a program-name. The first 10 characters of identifier-1 are used to associate the calling program with the called subprogram.

If you specify identifier-1, the call is classified as a dynamic call because the PROGRAM-ID is resolved at run time each time a call is made.

literal-1

Literal-1 must be nonnumeric, uppercase, and must follow the rules for formation of a program-name. The first 10 characters of the literal are used to associate the calling program with the called subprogram. The literal must specify the program-name of the called subprogram.

If you specify literal-1, the call is classified as a static call because the PROGRAM-ID is determined at compile time.

USING

The USING phrase makes data items defined in a calling program available to a called subprogram.

Include the USING phrase in the CALL statement only if there is a USING phrase in the Procedure Division header of the called subprogram. The number of operands in each USING phrase must be identical.

The order of appearance of USING identifiers in both the calling program and the called subprogram determines the relationship of single sets of data available to both programs. The relationship is positional and not by name. Corresponding identifiers must contain the same number of characters, although their data descriptions may be different.

Each USING identifier names data items available to the calling program that may be referred to in the called program. A given identifier may appear more than once. These items are defined in any Data Division section.

identifier-2

You must define identifier-2 as a level-01, level-77, or elementary data item in the File Section, Working-Storage Section or Linkage Section.

It can be:

You can specify up to 30 occurrences of this identifier.

REFERENCE

The value of a parameter passed through the BY REFERENCE phrase is evaluated when the CALL statement is executed. The value is assigned to the corresponding parameter of the called subprogram. The number of characters in each parameter must be equal, however the data descriptions need not be the same.

When a COBOL/400 parameter is passed BY REFERENCE, a pointer in the original data item is passed to the called subprogram. Thus, by changing a parameter in the called subprogram, the data item in the calling program is changed.

CONTENT

The value of a parameter passed through the BY CONTENT phrase is evaluated when the CALL statement is executed. The value is assigned to the corresponding parameter of the called subprogram. The number of characters in each parameter must be equal, however the data descriptions need not be the same.

For each COBOL/400 item passed BY CONTENT, a copy of the item is made in the calling program, and a pointer to this copy is passed to the called subprogram. Thus, any changes made to the parameter in the called subprogram, will not be reflected in the data item of the calling program.

ADDRESS OF

The ADDRESS OF special register exists for each record ( 01 or 77) in the Linkage Section, except for those records that redefine each other. In such cases, the ADDRESS OF special register is similarly redefined.

ADDRESS OF special register is implicitly defined USAGE IS POINTER.

When a pointer data item is passed in a CALL statement, the item is treated as all other USING items. That is, a pointer to the pointer data item (or copy of the pointer data item) is passed to the called subprogram.

LENGTH OF

LENGTH OF creates an implicit special register whose contents equal the current length, in bytes, of the data item referenced by the identifier.

In the Procedure Division, you can use the LENGTH OF special register anywhere a numeric data item having the same definition as the implied definition of the LENGTH OF special register is used. It is implicitly defined USAGE IS BINARY, PICTURE 9(9).

You can use the LENGTH OF special register in the BY CONTENT phrase of the CALL statement.

literal-2

Specify literal-2 as any of the following:

OVERFLOW imperative-statement-1

If you specify the ON OVERFLOW phrase in the CALL statement, control is transferred to imperative-statement-1 when the called subprogram cannot be made available.

file-name-1

File-name-1 must appear in an FD entry. It passes a pointer data item that refers to a File Information Block (FIB).


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