CreateOptEngine function
Syntax
CreateOptEngine(analytic_inst, {%Synch | %ASynch}[, &detailedstatus] [, processinstance])
Description
The CreateOptEngine function instantiates an OptEngine object, loads an optimization engine with an analytic instance and returns a reference to it.
Parameters
| Parameter | Description |
|---|---|
|
Analytic_inst |
Specify the analytic instance ID, which is a unique ID for this analytic instance in this optimization engine. This is supplied by users when they request that an optimization be run. |
|
%Synch | %Asynch |
Specify whether the optimization engine is synchronous or asynchronous. The values are:
|
|
&detailedstatus |
Specify a variable that the engine uses to give further information about the evaluation of this function. The value returned is one of the following:
|
|
processinstance |
Enter the process instance ID. You use this parameter only with lights-out processing, most likely with the subscription PeopleCode for application message. Note: This optional parameter is positional. If you use it, you must also use the &detailedstatus parameter. The state record that you use with Application Engine contains the process instance ID. |
Returns
If successful, CreateOptEngine returns an OptEngine PeopleCode object. If the function fails, it returns a null value. Examine the optional status reference parameter in case of a Null return for additional information regarding the failure.
Example
An OptEngine object variable can be scoped as Local, Component, or Global.
You declare OptEngine objects as type OptEngine. For example:
Local OptEngine &MyOptEngine;
Component OptEngine &MyOpt;
Global OptEngine &MyOptEng;
The following example loads an optimization engine with the analytic instance:
Local OptEngine &myopt;
Local string &probinst;
Local string &transaction;
Local integer &detailedstatus;
&probinst = GetRecord(Record.PSOPTPRBINST).GetField(Field.PROBINST).Value;
&myopt = CreateOptEngine(&probinst, %Synch);
The following example shows the use of the optional status parameter:
&myopt = CreateOptEngine(&probinst, %Synch, &detailedstatus);
if &myopt = Null then
if &detailedstatus = %OptEng_Invalid_Piid then
/*perform some action */
end_if;
end_if;