RunSynch method: OptEngine class
Syntax
RunSynch(TRANSACTION, PARM_PAIRS)
Description
The RunSynch method requests the optimization engine to run the transaction in synchronous mode.
When using the DetailedStatus OptEngine property, keep the following in mind:
-
The value returned by RunSynch is the operational status of the optimization engine.
-
The DetailedStatus OptEngine property indicates the completion status of the OptEngine method call RunSynch.
For example, RunSynch can return %OptEng_Fail and DetailedStatus is %OptEng_DB_Updates_Pending. For RunSynch, DetailedStatus can have the value:
-
%OptEng_Success: indicates that the function completed successfully.
-
%OptEng_Fail: indicates that the function failed.
-
%OptEng_Method_Disabled: indicates that the method is disabled or not valid.
-
%OptEng_DB_Updates_Pending: indicates that database updates are pending.
Parameters
| Parameter | Description |
|---|---|
|
TRANSACTION |
Enter a string for the name of the transaction to run. |
|
PARAM_PAIRS |
Enter the name and value pairs (string name and value) for this transaction. Not used if the transaction has no parameters. Parameters are defined in the analytic type definition. See Optimization Framework: Configuring Analytic Type Transactions. |
Returns
This method returns a constant. Valid values are:
| Value | Description |
|---|---|
|
%OptEng_Success |
Returned if method succeeds. |
|
%OptEng_Fail |
Returned if the method fails. |
Example
The following PeopleCode example runs a synchronous optimization transaction named IS_MACHINE_AVAILABLE. It has these parameters:
-
Input MACHINE_NAME to specify the machine.
-
Inputs BEGIN_DATE and END_DATE to specify the time slot.
-
Output AVAILABLE_FLAG to specify whether the machine is available in that time slot.
This PeopleCode example sets input parameter values and gets an output parameter value:
Local OptEngine &myopt;
Local integer &status;
Local string &machname;
Local datetime &begindate;
Local datetime &enddate;
&myopt = GetOptEngine("PATSMITH");
&machname = QEOPT_WRK.MACHINE_NAME.Value;
&begindate = QEOPT_WRK.BEGIN_DATE.Value;
&enddate = QEOPT_WRK.END_DATE.Value;
/* Run the IS_MACHINE_AVAILABLE transaction synchronously with input values. */
&status = &myopt.RunSynch("IS_MACHINE_AVAILABLE",
"MACHINE_NAME", &machname, "BEGIN_DATE", &begindate, "END_DATE", &enddate);
If &status=%OptEng_Fail Then
QEOPT_WRK.MESSAGE_TEXT = "IS_MACHINE_AVAILABLE transaction failed.";
Return;
End-If;
/* Get output value from the IS_MACHINE_AVAILABLE transaction. */
QEOPT_WRK.AVAILABLE_FLAG = &myopt.GetNumber("AVAILABLE_FLAG");
Or, the following example shows the use of the DetailedStatus property.
Local integer &status;
&status = myopt.RunSynch("SOLVE");
if &status=%OptEng_Fail and &myopt.DetailedStatus=%OptEng_Method_Disabled then
<perform some action>
End-if;