Skip to main content

Calling sub programs, total size limitation

  • February 15, 2013
  • 0 replies
  • 0 views

Problem:

Calling sub programs, total size limitation.

Queston is about the "1020 limit" noted in the documentation.

"The total size of all the parameters passed must not exceed 1020 bytes, where each BY REFERENCE and BY CONTENT parameter occupies 4 bytes."

This limit would permit the passing of 255 "by reference" parameters in a single call statement.

This limitation is documented in Net Express Help under:

Programming

......Calling Programs

..........Passing parameters to a called program

Resolution:

The complete article from Net Express Help

Passing Parameters to a Called Program

Parameters are passed 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.

Parameters can be passed in the following formats. The program can pass the:

Address of a data item, using the USING BY REFERENCE or USING BY CONTENT phrase. Any changes that the called program makes to a parameter passed BY REFERENCE are reflected in the calling program, whereas any changes made to a parameter passed BY CONTENT are not reflected in the called program.

For example, the following statement passes the address of parameter-1:

CALL "program-name" USING BY CONTENT parameter-1

Value of a data item, using the USING BY VALUE phrase. Any changes made to the parameter in the called program are not reflected in the calling program.

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 is 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.

Old KB# 5177