1. Header

A procedure division header consists of the USING paragraph and the RETURNING paragraph.

figure pd program procedure division header
Program Procedure Division Header Format

Each paragraph is described as follows:

  • USING paragraph

    • The USING paragraph is specified to receive parameters from a called program.

    • To receive data through USING, a data item must be described as level-01 or 77 in the linkage section of the called program. To pass data to a subprogram using CALL, a data item from the parameter to be transmitted must be described in the data division of the called program.

      Items specified in the linkage section must satisfy one of the following conditions.

      • Are operands specified in the USAGE paragraph

      • Are operands of SET ADDRESS OF and CALL …​ BY REFERENCE ADDRESS OF

      • Are operands which satisfy the previous conditions and where REDEFINES or RENAMES is defined

      • Are subitems of an item that satisfies the previous conditions

      • Are condition-names or index-names that satisfy any of the previous conditions

    • The USING paragraph can be used to pass data from non-COBOL programs to COBOL programs, and vice versa.

    • The relationship between parameters passed from calling programs and those passed to called programs is determined by the positions of the specified parameters rather than by their names. Corresponding identifiers in calling and called programs do not need to have the same data description, but the number of bytes must be the same.

    • Parameters can be passed either in the BY REFERENCE or the BY VALUE phrase. For further information, refer to CALL.

  • RETURNING paragraph

    • The RETURNING paragraph is specified to pass a value to a calling program.

    • data-name2 must be specified as level-01 or level-77 in the linkage section of the program.

    • The RETURNING data item is an output-only data item. In the initial state of the program, the value of a data item is unpredictable. Initialize the RETURNING data item before referencing it. For more information, refer to CALL.