Sometimes you need to Re initialize application angine state record (AET) to its default values in your steps other than the first one. Instead of using the SetDefault peoplecode for each field of the state record, you can do this using a simple peoplecode function in peoplecode action or using %SelectInit Meta SQL construct in SQL action.
PeopleCode Solution.
Function SetDefaultValues(&rec As Record)
For &I = 1 To &rec.FieldCount
&statefld = &rec.GetField(&I);
/* PROCESS_INSTANCE is a reserved state field that cannot be modified */
If &statefld.Name <> "PROCESS_INSTANCE" Then
&rec.GetField(&I).SetDefault();
End-If;
End-For;
End-Function;
/* Sample PeopleCode to Call this function */
Declare Function SetDefaultValues PeopleCode FUNCLIB_UTIL.FUNCTION_FIELD FieldFormula;
Local Record &staterec;
Local Field &statefld;
/* Get the Record variable for the State Record) */
&staterec = GetRecord(Record.GF_ATTACH_AET);
MY_AET.OPRID = "xxxxxx";
MessageBox(0, "test", 0, 0, "Oprid before default = " | MY_AET.OPRID);
SetDefaultValues(&staterec);
MessageBox(0, "test", 0, 0, "Oprid after default = " | MY_AET.OPRID);
Note: MessageBox function in application engine peoplecode generates the entry in Message Log and can be viewd in process monitor using Log/Details link.
SQL Step Solution
You can add the SQL Step and use %SelectInit to initialize the State Record.
you can include a SQL Step with following values
%Select Init(State Record fields1, State Record fields2)
select 'x', 'x', 'x' ..... from ps_installation where 1 = 2
This meta-SQL construct is identical to %SELECT with the following exception?if the SELECT returns no rows, %SelectInit reinitializes the buffers. In the case of a %SELECT and no rows are returned, the state record fields retain their previous values.
3 comments:
Hey nice post. I keep coming to your blog all the time.
Pranav
Excellent...
It really helped for budding programer like me
You have provided a very good peoplesoft application knowledge.Thanks for sharing.
Post a Comment