Invoking a Public Segment Method from an External Program

Passing Data

Routines expect one word-aligned parameter upon invocation. The parameter must match the input parameter format of the Public Segment method.

Example of Calling a Coroutine from COBOL

The following code is an example of calling a coroutine from COBOL.

IDENTIFICATION DIVISION.
PROGRAM-ID. TEST-PROG.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 S-FUNC 						PIC X(5).
01 S-NAME 						PIC X(20).
01 S-STATUS 					PIC X(5).
LOCAL-STORAGE SECTION.
LD MYPARAMS.
01 PARAM_E PIC X(100).
PROGRAM-LIBRARY SECTION.
LB EXPORTLIB IMPORT COMMON
ATTRIBUTE LIBACCESS BYTITLE.
* Methods exported as defined name.
ENTRY PROCEDURE PUBMETHNAME
WITH MYPARAMS
USING PARAM_E, PARAM_E, PARAM_E.
PROCEDURE DIVISION.
GLB-MAIN-METHOD SECTION.
GLB-ENTER.
CHANGE ATTRIBUTE TITLE OF EXPORTLIB TO
* Library name is created as <appl>/EXPORTS/LIBRARY
"(TESTUSER)TEST/EXPORTS/LIBRARY.".
MOVE "READ" TO S-FUNC.
MOVE "SMITH" TO S-NAME.
CALL PUBMETHNAME USING S-FUNC, S-NAME, S-STATUS.
IF S-STATUS = SPACES
	DISPLAY "Record Found"
ELSE
	DISPLAY "Record does not exist".
STOP RUN.

Technical Note

The exported method executes as a coroutine within the exports library to provide database transaction state independence should the calling program also be updating the Agile Business Suite database directly (otherwise you might hit a DMS II Auditerror). This is effectively a 'SAFE' entrypoint in that in can be used in all circumstances regardless of what the caller program is doing

Another entrypoint is also exported from the exports library for every public segment method. This entry point is a true call to the method without the co-routine wrapper. Hence, it performs better performance but user onus applies in that it is not suitable if the caller program is also updating the Agile Business Suite application database directly. This entrypoint is exported as <method name>_DIRECT and could be considered 'UNSAFE' as the functionality of the caller must be known before it can be safely used.

Regardless of the entrypoint used, the integrity of the transaction state is assured as each call might only result in a maximum of one transaction state which is committed before returning to the caller.