To use PL/I subroutines executing under the control of a COBOL Application you need to initialize the PL/I runtime prior to invoking the PL/I program and shut it down before termination. The initialization call (__lpi_init()) can be made within a COBOL "initcall" program, but the de-initialization call (__lpi_fini_and_return() ) must not be made from a COBOL EXIT Proc as the processing happens after the File Handler has closed all open files at step termination and will result in any buffered stream output being lost.
A very simple example COBOL program which initializes the PL/I runtime, calls a PL/I subroutine and then terminates the PL/I runtime is shown below.
$SET CASE identification division. program-id. FETCHER. environment division. configuration section. special-names. call-convention 8 is litlink. data division. working-storage section. 01 pli-lang pic x(02) comp-5 value 0. 01 pli-retcode pic x(04) comp-5. 01 argv pointer value null. procedure division. *> Initialize PL/I RTS call litlink '__lpi_init' using by value 0 size 4 by reference argv by reference argv by value pli-lang *> Call the PL/I subroutine call 'PLISUB' *> Shutdown the PL/I RTS call litlink '__lpi_fini_and_return' using by value pli-lang by reference pli-retcode move 0 to return-code goback. end program FETCHER.