The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

Monday, 1 December 2014

Controlling Component Save Processing

I was recently working upon an issue where the PeopleCode changes bring upon the Save Warning message and which goes into loop even if the component is saved. I was researching on various options to turn off the Save Warning. I found a couple of methods and properties which controls or depends on the component save flag. Thought of documenting everything together so that people having similar issue could read the related methods and properties in a single place.

Before I go ahead, I may have to explain how the Save Warning is issued for a component. Whenever a component is loaded, the Component Processer holds a flag value which will store whether the component is changed or not. This flag is set whenever the user changes the value of a field on the online page or when the value of a field is changed via PeopleCode logic. Having this flag value, whenever user attempts to navigate away from the component, the Component Processor will check this flag and if its value is set then a Save Warning is issued otherwise it logs out of the component. The value of this particular flag is reset after every insert into the database (after Save Pre Change) which will prevent the warning when the user has already saved the component. However a code in your Save Post Change could set the flag again.
Now let us discuss about some of the functions and properties which could be potentially helpful in tackling the Save Warning issues in PeopleSoft.

ComponentChanged() – This function will return a Boolean value based on if the component was changed after last save. You could use this function to determine the component level flag value which we discussed earlier and based on that you could write your logic.

Eg: 
If ComponentChanged() Then
Rem Write your logic here;
WinMessage(“Your Message Text”,0);
Else
Transfer(….);
End-If;

SetComponentChanged() – You can use this function to set the component level flag programmatically. Sometimes it may be required that even if the user has not changed any value on the page, when he/she clicks a button on the page the system needs to do the save processing. This is the function which could help you do this. This will initiate the Save Warning or Save Processing even if nothing has changed in the component.

Eg: 
Rem Initiate Save Processing;
SetComponentChanged();
DoSaveNow();

SetSaveWarningFilter() – Use this function to supress the Save Warning irrespective of whether the component level flag is set or not. If you use this function the component processor will ignore the component level flag value and let the user to navigate away from the component without issuing any Save Warning. This function takes a Boolean value as argument. Passing True will direct the component processor to ignore the flag whereas passing an argument of False will make the component behave in its normal way.

Eg: 
REM changing the field value of DESCR;
&myRec.DESCR.Value = “My Description”;
SetSaveWarningFilter(True);
REM Now the system will not issue Save Warning to the User;
REM To bring back the warning call the same function with parameter False;

Set Component Changed (Page Field Property) – Sometimes, for certain fields, even if the user changes some value on the online page we may not require to initiate the Save Processing or issue the Save Warning. This page field level property comes handy in those scenarios.

Set Component Changed property of page field


This property can be found in the Use tab of the page field property. This will determine if the component flag needs to be set when the user changes the value of the field. This property determines the behavior only for user intervention and does not govern the PeopleCode changes.

Disable Saving Page (Component property) – If the entire purpose of the component you have designed is to just display information or to act as an intermediate component, then you can use this property to avoid the Save warning. This property can be found on the Use tab of the component.


Disable Saving Page component property


Checking this field will hide the save button from the component and will suppress the save warning. If you want to permanently suppress the Save Warning for the entire component this is the best option to choose as it provides the mechanism to achieve the objective with minimal impact.

IsChanged Property – This property is available for the objects Field, Record and Row. This property will return a Boolean value indicating whether the object has changed or not. This property will be helpful in doing some special processing for which you need to dynamically know which object has changed.

Eg:
Local Number &I;
&I = 1;
Rem Loop through the record to find out the changed field;
For &I = 1 To &myRecord.FieldCount
If &myRecord.GetField(&i).IsChanged Then
Rem Custom Logic;
End-If;
End-For;

SetComponentChanged (Property) – This property is read-write and is available in both Field and Rowset Level. Setting this value to True indicates the component processor that any change to the Field/Rowset using a PeopleCode will set the component save flag and the Save Warning needs to be issued. A value of False will not set the component changed flag when the Field/Rowset value is changed using a PeopleCode. The example provided below will illustrate the use of the property where a value of a field is changed programmatically without requiring/ initiating a Save Warning.

Eg:
REM Change the field DESCR without requiring a user Save;
&myRec.DESCR.SetComponentChanged = False;
&myRec.DESCR.Value = “New Description”;
REM Re-set the property so that a change to the field made by the user prompts a save;
&myRec.DESCR.SetComponentChanged = True;




4 comments:

Followers