PeopleCode | Call an App Engine program immediately
A. Preliminary
One of the benefits of Application Engine programs is that they can be run as batch processes (via the Process Scheduler) or they can be run immediately in PeopleCode via the user of the ‘CallAppEngine’ function. Unlike scheduling a process, an App Engine called via ‘CallAppEngine’ will run to completion before the system continues with further code.
However, there’s a major proviso here. Many App Engine programs are developed under the assumption that a run control record is populated in advance, and that the AE will only be run via the Process Scheduler. Therefore, you may need to firstly check the App Engine to see what its requirements are in terms of run control records. If a run control record is needed, a better option would be to create the run control record and then schedule an App Engine process via ‘CreateProcessRequest’ (refer to Tip 010 reference below).
If the App Engine does have the ability to be run immediately as part of online PeopleCode, you also need to consider what database tables must be populated in advance. If, for instance, the user is mid-way through processing data on a component, you will need to consider the most appropriate place to call the App Engine. You may have to perform an early ‘DoSave()’ before continuing with ‘CallAppEngine’. Therefore, a likely event to include a ‘CallAppEngine’ statement would be ‘FieldChange’ or ‘SavePostChange’.
B. Using CallAppEngine
After all that, if you still decide to continue with ‘CallAppEngine’, you can populate the state record directly with the appropriate values before calling the App Engine:
/* Set the state record for the App Engine */ Local Record &stateRec; &stateRec = CreateRecord(Record.STATE_REC_AET); &stateRec.EMPLID.Value = ¤tEmplID; &stateRec.ITEM_TYPE.Value = ¤tItemType; CallAppEngine("APP_ENG", &stateRec);
See Also:
Tip 010: Create Process Request
Tip 027: Dynamic App Engine Call Section