This Section will discuss about various PeopleCode that need to write In order to AWE Work properly.
Please Follow AWE Workflow Other 4 Parts.
- Part 1 – Contains Record , Component , Pages & Menu Creation ( Create A Simple AWE PeopleSoft )
- Part 2 – Contains AWE Transaction Registration , Configuration , Approval Process & Generic Template Setup in thru PeopleSoft Portal ( Create A Simple AWE PeopleSoft Part – 2 )
- Part 3 – Contains Testing & Demonstration AWE Workflow in PeopleSoft with different User ( Create A Simple AWE PeopleSoft Part – 3 )
PeopleCode
People Code Type | ZZ_AWE_HDR Component Record Field Level |
Event Name | FieldChange |
Object Name | ZZ_AWE_ACTN_WRK.EOAW_SUBMIT |
/** Submit Button **/
Component string &c_sAppr_Action;
Component string &c_sSubmitBtn;
&c_sAppr_Action = "S";
If ( Not GetRow().IsChanged) Then
/** force save processing **/
SetComponentChanged();
End-If;
DoSave();
&c_sSubmitBtn = "Y";
People Code Type | ZZ_AWE_HDR Component Record Field Level |
Event Name | FieldChange |
Object Name | ZZ_AWE_ACTN_WRK.EOAW_SAVE |
/** Data Save As Draft **/
Component string &c_sAppr_Action;
Component string &c_sSaveDraftBtn;
&c_sAppr_Action = "V";
If ( Not GetRow().IsChanged) Then
/** force save processing **/
SetComponentChanged();
End-If;
DoSave();
&c_sSaveDraftBtn = "Y";
People Code Type | ZZ_AWE_HDR Component Record Field Level |
Event Name | FieldChange |
Object Name | ZZ_AWE_ACTN_WRK.EOAW_DENY |
/** Deny Button */
Component string &c_sAppr_Action;
&c_sAppr_Action = "D";
If ( Not GetRow().IsChanged) Then
/** force save processing **/
SetComponentChanged();
End-If;
DoSave();
People Code Type | ZZ_AWE_HDR Component Record Field Level |
Event Name | FieldChange |
Object Name | ZZ_AWE_ACTN_WRK.EOAW_APPROVE |
/** Approve Button **/
Component string &c_sAppr_Action;
&c_sAppr_Action = "A";
If ( Not GetRow().IsChanged) Then
/** force save processing **/
SetComponentChanged();
End-If;
DoSave();
People Code Type | ZZ_AWE_HDR Component Record |
Event Name | RowInit |
Object Name | ZZ_AWE_HDR |
If %Mode = %Action_Add Then
ZZ_AWE_HDR.EMPLID.Value = %EmployeeId;
End-If;
People Code Type | ZZ_AWE_HDR Component |
Event Name | PostBuild |
Object Name | ZZ_AWE_HDR |
/***
* AWE Post Build Code
* Application developers should instantiate ApprovalManager & LaunchManager class as a component-scoped variable.
* The best place to initialize ApprovalManager & LaunchManager class is in the component post-build event.
***/
/** Import Approval Framework Base Classes **/
import EOAW_CORE:LaunchManager;
import EOAW_CORE:ApprovalManager;
/** Declare functions*/
Declare Function createStatusMonitor PeopleCode EOAW_MON_WRK.EOAW_FC_HANDLER FieldFormula;
/** Declare Variables **/
Component EOAW_CORE:LaunchManager &c_aweLaunchManager;
Component EOAW_CORE:ApprovalManager &c_aweApprovalManager;
Component string &c_sAppr_Action;
Component string &c_AWEProcessDefnID;
Component Record &headerRec; /** We have set it Component Level, So Get Acess to Others Component **/
Local boolean &isApprover = False; /** Checl if User is Approver for this transaction **/
/** Set Header Record, **/
&headerRec = GetRecord(Record.ZZ_AWE_HDR);
/** Get Assigned Approval Process Id for selected transaction From Workflow Transaction Page **/
&c_AWEProcessDefnID = "ZZ_AWE_SAMPLE"; /** Get EO Process Defn ID **/
/** Initialize the launch and approval managers. ApprovalManager will need reinitialization on submit */
&c_aweLaunchManager = create EOAW_CORE:LaunchManager(&c_AWEProcessDefnID, &headerRec, %UserId);
&c_aweApprovalManager = create EOAW_CORE:ApprovalManager(&c_AWEProcessDefnID, &headerRec, %UserId);
/** Set Up Approval Process Defination **/
&c_aweLaunchManager.definition = "ZZ_AWE_SAMPLE";
/** Show Transaction Status Monitor & Save & Submit Button **/
If &c_aweApprovalManager.hasAppInst Then
createStatusMonitor(&c_aweApprovalManager.the_inst, "D", Null, False);
ZZ_AWE_ACTN_WRK.EOAW_SUBMIT.Visible = False;
ZZ_AWE_ACTN_WRK.EOAW_SAVE.Visible = False;
/* Toggle all fields with the exception of the status monitor as display only. We cannot
change the page property as the status monitor fields would be disabled */
Local Rowset &Rs = GetLevel0();
For &i = 1 To &Rs(1).RecordCount
&Rec = &Rs(1).GetRecord(&i);
For &j = 1 To &Rec.fieldcount
&Rs(1).GetRecord(&i).GetField(&j).DisplayOnly = True;
End-For;
End-For;
Else
ZZ_AWE_ACTN_WRK.EOAW_SUBMIT.Visible = True;
ZZ_AWE_ACTN_WRK.EOAW_SAVE.Visible = True;
End-If;
/*** Show Approve & Deny Button Based on Condition ***/
If &c_aweApprovalManager.hasPending And
&c_aweApprovalManager.GetParticipant(%UserId) = "AA" Then
ZZ_AWE_ACTN_WRK.EOAW_APPROVE.Visible = True;
ZZ_AWE_ACTN_WRK.EOAW_APPROVE.DisplayOnly = False;
ZZ_AWE_ACTN_WRK.EOAW_DENY.DisplayOnly = False;
ZZ_AWE_ACTN_WRK.EOAW_DENY.Visible = True;
ZZ_AWE_ACTN_WRK.EOAW_SUBMIT.Visible = False;
ZZ_AWE_ACTN_WRK.EOAW_SAVE.Visible = False;
Else
ZZ_AWE_ACTN_WRK.EOAW_APPROVE.Visible = False;
ZZ_AWE_ACTN_WRK.EOAW_DENY.Visible = False;
End-If;
/*** Show Approve & Deny & Save & Submit Button Based on Condition End ***/
People Code Type | ZZ_AWE_HDR Component |
Event Name | SavePreChange |
Object Name | ZZ_AWE_HDR |
/** Declare Component Variables **/
Component string &c_sSaveDraftBtn;
Component string &c_sSubmitBtn;
Component string &c_sAppr_Action;
If %Mode = %Action_Add Or
%Mode = %Action_UpdateDisplay Or
%Mode = %Action_UpdateDisplayAll Then
/** Perform Button Action **/
/** When Submit **/
If &c_sSubmitBtn = "Y" Then
ZZ_AWE_HDR.EMPLID.Value = %EmployeeId;
ZZ_AWE_HDR.SUBMIT_DTTM.Value = %Datetime;
&c_sSubmitBtn = "";
End-If;
/** When SaveAsDraft **/
If &c_sSaveDraftBtn = "Y" Then
ZZ_AWE_HDR.EMPLID.Value = %EmployeeId;
ZZ_AWE_HDR.WF_STATUS.Value = "V"; /** Set Data Saved As Draft **/
ZZ_AWE_HDR.SUBMIT_DTTM.Value = %Datetime;
&c_sSaveDraftBtn = "";
End-If;
End-If;
People Code Type | ZZ_AWE_HDR Component |
Event Name | SavePostChange |
Object Name | ZZ_AWE_HDR |
/***
* AWE SavePostChange Code
* This Save Post Change Code Will Handled When Submit, Approve & Deny Action Performed
**/
/** Import Approval Framework Base Classes */
import EOAW_CORE:LaunchManager;
import EOAW_CORE:ApprovalManager;
/** Declare functions*/
Declare Function createStatusMonitor PeopleCode EOAW_MON_WRK.EOAW_FC_HANDLER FieldFormula;
Component EOAW_CORE:LaunchManager &c_aweLaunchManager;
Component EOAW_CORE:ApprovalManager &c_aweApprovalManager;
Component string &c_sAppr_Action;
Component string &c_AWEProcessDefnID;
Component Record &headerRec; /** We have set it Component Level, So Get Acess to Others Component **/
Local boolean &IsActionTaken = True;
Local string &sActionMsgString = "";
Evaluate &c_sAppr_Action
When "V"
/* When Data Saved As Draft */
Break;
When "S"
/* Call DoSubmit, passing in current header info. ;*/
/** It is always safe to call this method (as long as the header record being passed in is valid!), */
&c_aweLaunchManager.SetHeader(&headerRec);
try
If &c_aweLaunchManager.hasAppDef Then
If &c_aweLaunchManager.submitEnabled Then
&c_aweLaunchManager.DoSubmit();
End-If;
End-If;
catch Exception &Ex1
&sActionMsgString = "Unable to DoSubmit on the ApprovalManager." | Char(10) | " Error - " | &Ex1.DefaultText;
&IsActionTaken = False;
end-try;
If (&c_aweLaunchManager.hasAppInst) Then
/** Initialize Approval Manager if transaction was submitted */
&c_aweApprovalManager = create EOAW_CORE:ApprovalManager(&c_aweLaunchManager.txn.awprcs_id, &headerRec, %UserId);
End-If;
Break;
When "A"
/* Call DoApprove, passing in current header info. */
try
&c_aweApprovalManager.DoApprove(&headerRec);
catch Exception &Ex2
&sActionMsgString = "Unable to DoApprove on the ApprovalManager." | Char(10) | " Error - " | &Ex2.DefaultText;
&IsActionTaken = False;
end-try;
Break;
When "D"
/* Call DoDeny, passing in current header info. */
try
&c_aweApprovalManager.DoDeny(&headerRec);
catch Exception &Ex3
&sActionMsgString = "Unable to DoDeny on the ApprovalManager." | Char(10) | " Error - " | &Ex3.DefaultText;
&IsActionTaken = False;
end-try;
Break;
When-Other
&sActionMsgString = "Error - Invalid Action.";
&IsActionTaken = False;
End-Evaluate;
/** Show Specified Action Message Box **/
If &sActionMsgString <> " " And
&IsActionTaken = False Then
MessageBox(0, "", 0, 0, &sActionMsgString);
/* Exit message processing. */
Exit (0);
End-If;
/** Show Transaction Status Monitor & Save & Submit Button **/
If &c_aweApprovalManager.hasAppInst Then
createStatusMonitor(&c_aweApprovalManager.the_inst, "D", Null, False);
ZZ_AWE_ACTN_WRK.EOAW_SUBMIT.Visible = False;
ZZ_AWE_ACTN_WRK.EOAW_SAVE.Visible = False;
ZZ_AWE_ACTN_WRK.EOAW_APPROVE.Visible = False;
ZZ_AWE_ACTN_WRK.EOAW_DENY.Visible = False;
/* Toggle all fields with the exception of the status monitor as display only. We cannot
change the page property as the status monitor fields would be disabled */
Local Rowset &Rs = GetLevel0();
For &i = 1 To &Rs(1).RecordCount
&Rec = &Rs(1).GetRecord(&i);
For &j = 1 To &Rec.fieldcount
&Rs(1).GetRecord(&i).GetField(&j).DisplayOnly = True;
End-For;
End-For;
End-If;
/* Reset &Action to Null */
&c_sAppr_Action = " ";
People Code Type | Application Package PeopleCode |
Event Name | OnExecute |
Object Name | ZZ_AWE_EVENT_HANDLR |
/***
* Approval Event Handler Class
* This Handle All the AWE Events
*Event values include:
*/
import EOAW_CORE:ApprovalEventHandler;
import EOAW_CORE:ENGINE:AppInst;
import EOAW_CORE:ENGINE:UserStepInst;
import EOAW_CORE:ENGINE:StepInst;
import EOAW_CORE:ENGINE:Thread;
class ApprEventHandler extends EOAW_CORE:ApprovalEventHandler
method ApprEventHandler();
method OnProcessLaunch(&appinst As EOAW_CORE:ENGINE:AppInst);
method OnStepComplete(&stepinst As EOAW_CORE:ENGINE:StepInst);
method OnHeaderApprove(&appinst As EOAW_CORE:ENGINE:AppInst);
method OnHeaderDeny(&userinst As EOAW_CORE:ENGINE:UserStepInst);
private
instance Record &HeaderRecord; /** Declare Record Instance **/
end-class;
/** Constructor */
method ApprEventHandler
%Super = create EOAW_CORE:ApprovalEventHandler();
&HeaderRecord = CreateRecord(Record.ZZ_AWE_HDR); /** Set the Header Record **/
end-method;
method OnProcessLaunch
/+ &appinst as EOAW_CORE:ENGINE:AppInst +/
/+ Extends/implements EOAW_CORE:ApprovalEventHandler.OnProcessLaunch +/; /** Set Approval Prcoess **/
Local string &HdrRecTopKeyValue;
&appinst.thread.SetAppKeys(&HeaderRecord);
&HeaderRecord.SelectByKey();
/** Retrieve Header field values **/
&HdrRecTopKeyValue = &HeaderRecord.GetField(Field.REQUEST_ID).Value;
/** Update the Workflow Status **/
Local Record &recHdrRecord = CreateRecord(Record.ZZ_AWE_HDR);
&recHdrRecord.GetField(Field.REQUEST_ID).Value = &HdrRecTopKeyValue;
If &recHdrRecord.SelectByKey() = True Then
&recHdrRecord.GetField(Field.WF_STATUS).Value = "I"; /** Set InApproval Process **/
&recHdrRecord.Update();
GetLevel0().Refresh();
End-If;
end-method;
method OnStepComplete
/+ &stepinst as EOAW_CORE:ENGINE:StepInst +/
/+ Extends/implements EOAW_CORE:ApprovalEventHandler.OnStepComplete +/
Local string &HdrRecTopKeyValue;
&stepinst.path.thread.SetAppKeys(&HeaderRecord);
&HeaderRecord.SelectByKey();
/** Retrieve Header Key field values **/
&HdrRecTopKeyValue = &HeaderRecord.GetField(Field.REQUEST_ID).Value;
/** Update the Workflow Status **/
Local Record &recHdrRecord = CreateRecord(Record.ZZ_AWE_HDR);
&recHdrRecord.GetField(Field.REQUEST_ID).Value = &HdrRecTopKeyValue;
If &recHdrRecord.SelectByKey() = True Then
&recHdrRecord.GetField(Field.WF_STATUS).Value = "I";
&recHdrRecord.Update();
GetLevel0().Refresh();
End-If;
end-method;
method OnHeaderApprove
/+ &appinst as EOAW_CORE:ENGINE:AppInst +/
/+ Extends/implements EOAW_CORE:ApprovalEventHandler.OnHeaderApprove +/
Local string &HdrRecTopKeyValue;
&appinst.thread.SetAppKeys(&HeaderRecord);
&HeaderRecord.SelectByKey();
/** Retrieve Header field values **/
&HdrRecTopKeyValue = &HeaderRecord.GetField(Field.REQUEST_ID).Value;
/** Update the Workflow Status **/
Local Record &recHdrRecord = CreateRecord(Record.ZZ_AWE_HDR);
&recHdrRecord.GetField(Field.REQUEST_ID).Value = &HdrRecTopKeyValue;
If &recHdrRecord.SelectByKey() = True Then
&recHdrRecord.GetField(Field.WF_STATUS).Value = "A";
&recHdrRecord.Update();
GetLevel0().Refresh();
End-If;
end-method;
method OnHeaderDeny
/+ &userinst as EOAW_CORE:ENGINE:UserStepInst +/
/+ Extends/implements EOAW_CORE:ApprovalEventHandler.OnHeaderDeny +/
Local string &HdrRecTopKeyValue;
&userinst.thread.SetAppKeys(&HeaderRecord);
&HeaderRecord.SelectByKey();
/** Retrieve Header field values **/
&HdrRecTopKeyValue = &HeaderRecord.GetField(Field.REQUEST_ID).Value;
/** Update the Workflow Status **/
Local Record &recHdrRecord = CreateRecord(Record.ZZ_AWE_HDR);
&recHdrRecord.GetField(Field.REQUEST_ID).Value = &HdrRecTopKeyValue;
If &recHdrRecord.SelectByKey() = True Then
&recHdrRecord.GetField(Field.WF_STATUS).Value = "D";
&recHdrRecord.Update();
GetLevel0().Refresh();
End-If;
end-method;
Please Follow AWE Workflow Other 4 Parts.
- Part 1 – Contains Record , Component , Pages & Menu Creation ( Create A Simple AWE PeopleSoft )
- Part 2 – Contains AWE Transaction Registration , Configuration , Approval Process & Generic Template Setup in thru PeopleSoft Portal ( Create A Simple AWE PeopleSoft Part – 2 )
- Part 3 – Contains Testing & Demonstration AWE Workflow in PeopleSoft with different User ( Create A Simple AWE PeopleSoft Part – 3 )
Please share your comments & let me know if you stuck on this Sample AWE Workflow.I will also share some advanced topics on approval framework , so stay tune.
Related Article you might like: