Try OpenEdge Now
skip to main content
Dynamic Call Object
Code examples : Multiple dynamic invokes from a temp-table
 

Multiple dynamic invokes from a temp-table

This example shows how a series of dynamic invokes of the call object can be set up using a temp-table, ttParam, whose handle is passed into the procedure:
/* ttParam is a temp-table that has one record with these fields:
   parm_1
   parm_2
   ...
   parm_n
   run-name
   nparms
   datatypes, extent nparms
   iomodes, extent nparms
*/

DEFINE INPUT PARAMETER TABLE-HANDLE ttParam NO-UNDO.

DEFINE VARIABLE hCall    AS HANDLE  NO-UNDO.
DEFINE VARIABLE hDtypes  AS HANDLE  NO-UNDO.
DEFINE VARIABLE hIOmodes AS HANDLE  NO-UNDO.
DEFINE VARIABLE ix       AS INTEGER NO-UNDO.

ASSIGN
  hDtypes  = ttParam:BUFFER-FIELD("datatypes")
  hIOmodes = ttParam:BUFFER-FIELD("iOmodes").

ttParam:FIND-FIRST.

CREATE CALL hCall.
ASSIGN
  hCall:CALL-NAME      = ttParam:BUFFER-FIELD("run-name"):BUFFER-VALUE
  hCall:NUM-PARAMETERS = ttParam:BUFFER-FIELD("nparms"):BUFFER-VALUE.

FOR ix = 1 TO hCall:NUM-PARAMETERS:
  hCall:SET-PARAMETER(ix, hDtypes:BUFFER-VALUE(ix),
    hIOmodes:BUFFER-VALUE(ix), ttParam:BUFFER-FIELD(ix):BUFFER-VALUE).
END.

hCall:INVOKE( ).
DELETE OBJECT hCall.
To implement this example, you must:
1. Define a temp-table record structure where each field represents one data item involved in dynamic invoke
2. Load the temp-table with a row of data for each dynamic invoke to be performed
3. Read the temp-table and performing a dynamic invoke for every record
Setting up a temp-table in this way allows an application to perform any number of dynamic invokes on the fly.