DoSaveNow function
Syntax
DoSaveNow()
Description
The DoSaveNow function is designed primarily for use with remote calls. It enables a PeopleCode program to save page data to the database before running a remote process (most frequently a COBOL process) that will access the database directly. It is generally necessary to call DoSaveNow before calling the RemoteCall function.
DoSaveNow causes the current page to be saved immediately. Save processing (including SaveEdit, SavePreChange, SavePostChange, and Workflow PeopleCode) is executed before continuing execution of the program where DoSaveNow is called. DoSaveNow differs from the DoSave function in that DoSave defers saving the component until after any running PeopleCode is completed.
DoSaveNow can only be called from a FieldEdit or FieldChange event.
If you call DoSaveNow and there are no changes to save, save processing is skipped entirely. You can call SetComponentChanged right before you call DoSaveNow. The SetComponentChanged function makes the Component Processor think there are changes and so will force full save processing.
Parameters
None.
Returns
None.
Example
The following example calls DoSaveNow to save the component prior to running a remote process in the remote_depletion declared function:
Declare Function remote_depletion PeopleCode FUNCLIB_ININTFC.RUN_DEPLETION Field⇒
Formula;
/*
Express Issue Page - run Depletion job through RemoteCall()
*/
If %Component = COMPONENT.EXPRESS_ISSUE_INV Then
DoSaveNow();
&BUSINESS_UNIT = FetchValue(SHIP_HDR_INV.BUSINESS_UNIT, 1);
&SHIP_OPTION = "S";
&SHIP_ID = FetchValue(SHIP_HDR_INV.SHIP_ID, 1);
remote_depletion(&BUSINESS_UNIT, &SHIP_OPTION, &SHIP_ID, &PROGRAM_STATUS);
End-If
Errors in DoSaveNow Save Processing
DoSaveNow initiates save processing. It handles errors that occur during save processing as follows:
-
If save processing encounters a SaveEdit error, it displays the appropriate message box. DoSaveNow immediately exits from the originating FieldChange or FieldEdit program. The user can correct the error and continue.
-
If save processing encounters a fatal error, it displays the appropriate fatal error. DoSaveNow handles the error by immediately exiting from the originating FieldChange or FieldEdit program. The user must then cancel the page.
-
If save processing completes with no errors, PeopleCode execution continues on the line after the DoSaveNow call in FieldChange or FieldEdit.
Restrictions on Use of DoSaveNow
The following restrictions apply:
-
DoSaveNow can be executed only from a FieldEdit or FieldChange event.
-
DoSaveNow is only allowed prior to the first CallAppEngine function in a FieldChange event, but not afterward.
-
Deferred operations should not be called before the DoSaveNow. Deferred operations include the DoSave, TransferPage, SetCursorPos, and EndModal functions.
-
Components that use DoSaveNow must not use the DoCancel, Transfer, TransferPage, or WinEscape functions in PeopleCode attached to save action events (SaveEdit, SavePreChange, and SavePostChange), because these functions terminate the component, which would cause the program from which DoSaveNow was called to terminate prematurely.
Note:
You should be aware that DoSaveNow may result in unpredictable behavior if PeopleCode in save events deletes rows or inserts rows into scrolls. PeopleCode that runs after DoSaveNow must be designed around the possibility that rows were deleted or inserted (which causes row number assignments to change). Modifying data on a deleted row may cause it to become “undeleted.”