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.
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
/* 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);
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.