Change COBOL Main Program (QLRCHGCM) API


  Required Parameter

1 Error code I/O Char(*)

  Default Public Authority: *USE

  Threadsafe: No

The Change COBOL Main Program (QLRCHGCM) API allows you to create an additional run unit by assigning a different System/36™-compatible COBOL, System/38™-compatible COBOL, or COBOL/400® program to serve as a main program. You can call it from any programming language.

Note: By creating more than one run unit, you can treat files, storage, and error conditions differently than you would using an ordinary subprogram.

After you call this API, the next nonactive COBOL program that runs becomes the main program in a new run unit. An active COBOL program is a program that has been called, and is not in its initial state.

In the following example, System/38-compatible COBOL Program A calls the COBOL/400 Program B. Because Program A is the first COBOL program, it is the main COBOL program.

COBOL Program B is a menu program that calls CL Program C.

Program C must start a new COBOL application that will pass control back to it, regardless of error conditions. To accomplish this, Program C calls the QLRCHGCM API before calling the new COBOL application.

When program C calls the new COBOL application in the form of Program D, Program D becomes the main program in a new run unit. When Program D's run unit ends, control returns to the original run unit, and Program A becomes the current main program again.

If, at the time a run unit is created, a program is active as a subprogram in an existing run unit, and this program is then called within the new run unit, it will be made available in its last-used state.

Graphical depiction of the preceding text


Authorities and Locks

None.


Required Parameter

Error code
I/O; CHAR(*)

The structure in which to return error information. For the format of the structure, see Error code parameter.


Error Messages

Message ID Error Message Text
CPF3C90 E Literal value cannot be changed.
LBE7040 E Format of error code parameter is not correct.


API introduced: V2R2

[ Back to top | High-level language APIs | APIs by category ]