Calling a Coroutine Using External Classes

To call a coroutine using the methods of external classes, perform the following:

  1. Create an external class in the model. The name can be any ABS legal name.

    During migration, an external class is created in the model with the name concatenated from the library path, pack name and usercode, and this class is prefixed with 'CoRoutine_" and postfixed with "_Lib". For example, a class named CoRoutine_SYS2_REPORT2_PACK_X_USER_Z_Lib.

  2. Set the following configuration property for the external class:

    • Set Library Name to the report name.

    • Set the Library Pack to pack name.

    • Set the Library Usercode to usercode.

    • Set the As Coroutine to True.

  3. Add a method to CoRoutine class called report.

  4. Add a method to CoRoutine class called report.

  5. Call the couroutine using the following code.

    CoRoutine_Lib.<report>(GLB.PARAM)

Transaction recovery strategies should consider that a coroutine called from an Ispec is a separate DMSII transaction from that Ispec's transaction.

Note: If you use Glb.Param in CALL; commands between applications, the maximum size of Glb.Param defined in the calling application and the called application must be the same.

Example of Calling a Coroutine from Logic

The following logic is an example of calling a Coroutine.

Prerequisite:

In the logic where you want to call the coroutine you have the following logic:

Move "READ" S_FUNC
Move "SMITH" SNAME
TheCoroutine.report( PARAM_GROUP )
DoWhen GLB.CORSTATUS = GLB.SPACES
Else
Message GLB.CORSTATUS "Coroutine invocation has given an error"
EndExit
Move GLB.PARAM PARAM_GROUP
DoWhen S_STATUS = "*****"
Message Error "Record doesn’t exist in database"
EndExit