Save Processing
A user can direct the system to save a component by clicking Save or by pressing Alt+1.
An application can prompt the user to save a component when the Next or List button is clicked, or when a new action or component is selected. If the user clicks Save after being prompted, save processing begins.
The following actions occur in save processing:
1) The Component Processor initiates the SaveEdit PeopleCode event, which triggers any SaveEdit PeopleCode associated with a record field or a component record.
This enables you to cross-validate page fields before saving, checking consistency among the page field values. An Error statement in SaveEdit PeopleCode displays a message and then redisplays the page, stopping the save. A Warning statement enables the user to cancel save processing by clicking Cancel, or to continue with save processing by clicking OK.
2) The Component Processor initiates the SavePreChange event, which triggers any SavePreChange PeopleCode associated with a record field, a component record, or a component.
SavePreChange PeopleCode enables you to process data after validation and before the database is updated.
3) The Component Processor initiates the Workflow event, which triggers any Workflow PeopleCode associated with a record field or a component.
Workflow PeopleCode should be used only for workflow-related processing (TriggerBusinessEvent and related functions).
4) The Component Processor updates the database with the changed component data, performing any necessary SQL Insert, Update, and Delete statements.
5) The Component Processor initiates the SavePostChange PeopleCode event, which triggers any SavePostChange PeopleCode associated with a record field, a component record, or a component.
6) You can use SavePostChange PeopleCode for processing that must occur after the database update, such as updates to other database tables not in the component buffer.
7) The Component Processor issues a SQL Commit statement to the database server.
8) The Component Processor redisplays the component
Important! Never use an Error or Warning statement in any save processing event other than SaveEdit. Perform all component data validation in SaveEdit.
Reference peoplebooks
flowchart of save processing
if you write to update other table in pre change depends on status of
current component, you may get wrong data .
Because the component can fail at any time after pre change.
For example you want to update location of employee to other table each
time a transfer happened, for this if you write sql in save pre change, the
new location will be updated in other table first, then an
error happened in post change so system will roll back the changes
in original component
and will have the old location only But your table saving location already
got updated & will have new location. But if you write in save post change
it will update only when original component saved successfully.
As I know that
Save Pre Change is the last event where we can save/manipulate the Component Buffer data. after this event we can not modify our component buffer data .
Save Post Change is for update/insert/Delete the data in record which are not associated with Component buffer.
> BUT we can manipulate the other record (Which are not associated with Component buffer) also in Save Pre Change so what is the use of Save Post Change ?
An application can prompt the user to save a component when the Next or List button is clicked, or when a new action or component is selected. If the user clicks Save after being prompted, save processing begins.
The following actions occur in save processing:
1) The Component Processor initiates the SaveEdit PeopleCode event, which triggers any SaveEdit PeopleCode associated with a record field or a component record.
This enables you to cross-validate page fields before saving, checking consistency among the page field values. An Error statement in SaveEdit PeopleCode displays a message and then redisplays the page, stopping the save. A Warning statement enables the user to cancel save processing by clicking Cancel, or to continue with save processing by clicking OK.
2) The Component Processor initiates the SavePreChange event, which triggers any SavePreChange PeopleCode associated with a record field, a component record, or a component.
SavePreChange PeopleCode enables you to process data after validation and before the database is updated.
3) The Component Processor initiates the Workflow event, which triggers any Workflow PeopleCode associated with a record field or a component.
Workflow PeopleCode should be used only for workflow-related processing (TriggerBusinessEvent and related functions).
4) The Component Processor updates the database with the changed component data, performing any necessary SQL Insert, Update, and Delete statements.
5) The Component Processor initiates the SavePostChange PeopleCode event, which triggers any SavePostChange PeopleCode associated with a record field, a component record, or a component.
6) You can use SavePostChange PeopleCode for processing that must occur after the database update, such as updates to other database tables not in the component buffer.
7) The Component Processor issues a SQL Commit statement to the database server.
8) The Component Processor redisplays the component
Important! Never use an Error or Warning statement in any save processing event other than SaveEdit. Perform all component data validation in SaveEdit.
Reference peoplebooks
flowchart of save processing
---------------------------------------------------------------------------------------------------------------------------------------------------------------
--> Will the Component Processor save the data in the Component Buffer to the Database if an Error occurs in the SavePostChange PeopleCode?
During the SavePostChange event execution if error or warning occur then it will be run time error. only after the successful complication of SavePostChange the system issues the SQL COMMIT. So the data that is in the Component Buffer will not save to the Database.
No, the Component Processor will not save the data in the Component Buffer to the Database if an Error occurs in the SavePostChange PeopleCode, because only after the successful complication of SavePostChange the system issues the SQL COMMIT.
----------------------------------------------------------------------------------------------------------------------------------------------
The difference is more into functional than technical. You can write sql to
update other tables in both SAVE PRE change & POST change it will work. But if you write to update other table in pre change depends on status of
current component, you may get wrong data .
Because the component can fail at any time after pre change.
For example you want to update location of employee to other table each
time a transfer happened, for this if you write sql in save pre change, the
new location will be updated in other table first, then an
error happened in post change so system will roll back the changes
in original component
and will have the old location only But your table saving location already
got updated & will have new location. But if you write in save post change
it will update only when original component saved successfully.
----------------------------------------------------------------------------------------------------------------------------------------------
I have very basic question .
Difference Between Save Pre Change And Save Post Change? As I know that
Save Pre Change is the last event where we can save/manipulate the Component Buffer data. after this event we can not modify our component buffer data .
Save Post Change is for update/insert/Delete the data in record which are not associated with Component buffer.
> BUT we can manipulate the other record (Which are not associated with Component buffer) also in Save Pre Change so what is the use of Save Post Change ?
----------------------------------------------------------------------------------------------------------------------------------------------
Understanding Save action events
The SaveEdit event is intiated whenever a user attempts to save the component. You can use SaveEdit PeopleCode to validate the consistency of data in component fields. Whenever a validation involves more than one component field, you should use SaveEdit PeopleCode.
- The component processor applies SaveEdit peoplecode to all non-deleted rows of data in the buffers & all pages in component
- SaveEdit is better suited than FieldEdit if the validation refrences more than one field or row of data.
- An Error statement in SaveEdit PeopleCode displays a message and redisplays the component without saving data. A Warning statement enables the user to click OK and save the data, or to click Cancel and return to the component without saving.
- Use the SetCursorPos function to set the cursor position to a specific page field following a warning or error in SaveEdit, to show the user the field (or at least one of the fields) that is causing the problem. Make sure to call SetCursorPos before the error or warning, because these may terminate the PeopleCode program.
- Associated with record fields and Components.
When an error message is issued in PeopleSoft(Component Processor) from the SAVEEDIT event, the cursor will not be directed to the corresponding field (value) for which the message is thrown. And the field also doesnot turn into red color as is the behaviour with the error messages issued from the FIELDEDIT event. UseSetCursorPos as shown above to set the cursor position. Here is example below written in SAVEEDIT.
IF NONE(RECORD1.FIELD1) THEN |
RECORD1.FIELD1.Setcursorpos(%Page); |
REM To Display field in Red Color |
RECORD1.FIELD1.Style = "PSERROR" ; |
Error ( "The Field is Required" ); |
END-IF; |
The SavePreChange event is initiated after SaveEdit completes without errors.
- SavePreChange PeopleCode provides one final opportunity to manipulate data before the system updates the database; for instance, you could use SavePreChange PeopleCode to set sequential high-level keys
- If SavePreChange runs successfully, a Workflow event is generated, and then the Component Processor issues appropriate Insert, Update, or Delete SQL statements.
- An Error statement in SaveEdit PeopleCode displays a message and redisplays the component without saving data. A Warning statement enables the user to click OK and save the data, or to click Cancel and return to the component without saving.
- Used to change display characteristics and validations
- SavePreChange PeopleCode can be associated with record fields, components, and component records.
After the Component Processor updates the database, it initiates the SavePostChange event. You can use SavePostChange PeopleCode to update tables not in your component using the SQLExec built-in function.
- Performs after SavePreChange and Workflow have completed successfully. SavePostChange is not executed if workflow fails or component is not saved due to any error.
- Donot use Error and Warnings in this event
- The system issues a SQL Commit statement after SavePostChange PeopleCode completes successfully.
- Other than updating tables that are not in your component, it is also used to send an email , say for approval.
- SavePostChange PeopleCode can be associated with record fields, components, and component records.
No comments:
Post a Comment