Create A Simple AWE PeopleSoft

This Section will discuss about various PeopleCode that need to write In order to AWE Work properly.

Please Follow AWE Workflow Other 4 Parts.

  1. Part 1 – Contains Record , Component , Pages & Menu Creation ( Create A Simple AWE PeopleSoft )
  2. Part 2 – Contains AWE Transaction Registration , Configuration , Approval Process & Generic Template Setup in thru PeopleSoft Portal ( Create A Simple AWE PeopleSoft Part – 2 )
  3. Part 3 – Contains Testing & Demonstration AWE Workflow in PeopleSoft with different User ( Create A Simple AWE PeopleSoft Part – 3 )

<img class="aligncenter size-full wp-image-1343" src="http://2.bp.blogspot.com/-xzixXNLYGTc/VKE678tXgGI/AAAAAAAAA7I/sdb4c_Wt760/s1600/2014122700078.png" alt=" " border="0" />

 

<img class="aligncenter size-full wp-image-1343" src="http://2.bp.blogspot.com/-L9mRDwWH6iA/VKE676I8gFI/AAAAAAAAA7A/vZPtrNVyUFs/s1600/2014122700079.png" alt=" " border="0" />

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";

<img class="aligncenter size-full wp-image-1343" src="http://2.bp.blogspot.com/-0PFMmO-mI3M/VKE68F8O-LI/AAAAAAAAA7E/hbsj2l__S_0/s1600/2014122700080.png" alt=" " border="0" />

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";

 

<img class="aligncenter size-full wp-image-1343" src="http://4.bp.blogspot.com/-CQvf4glU-ls/VKE684CZcgI/AAAAAAAAA7M/dFiReEYG6Es/s1600/2014122700081.png" alt=" " border="0" />

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();

<img class="aligncenter size-full wp-image-1343" src="http://1.bp.blogspot.com/-GaxrVk-Skfs/VKE69D6SvwI/AAAAAAAAA8A/HeRPAJssSCA/s1600/2014122700082.png" alt=" " border="0" />

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();

<img class="aligncenter size-full wp-image-1343" src="http://3.bp.blogspot.com/-d-Tc5ewRU5c/VKE69kRPp6I/AAAAAAAAA7U/jrCyjaMZ9-8/s1600/2014122700083.png" alt=" " border="0" />

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;

<img class="aligncenter size-full wp-image-1343" src="http://3.bp.blogspot.com/-18c_tWi2jB0/VKE6-Eucj-I/AAAAAAAAA7Y/ckn80x8Lb9k/s1600/2014122700084.png" alt=" " border="0" />

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 ***/

<img class="aligncenter size-full wp-image-1343" src="http://1.bp.blogspot.com/-3x30aKApmyI/VKE6_MUjKoI/AAAAAAAAA7c/A4-7He8Hwww/s1600/2014122700085.png" alt=" " border="0" />

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;

<img class="aligncenter size-full wp-image-1343" src="http://2.bp.blogspot.com/-a1LrE7L9ubg/VKE6_pYme-I/AAAAAAAAA7k/dnhbDUB84_g/s1600/2014122700086.png" alt=" " border="0" />

 

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 = " ";

<img class="aligncenter size-full wp-image-1343" src="http://4.bp.blogspot.com/-x5ovRT0zBxI/VKE7AGKTd4I/AAAAAAAAA7o/DMgwc8mUUJU/s1600/2014122700087.png" alt=" " border="0" />

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;

<img src="http://2.bp.blogspot.com/-SOK-U_HHOXo/VKFDix3vW2I/AAAAAAAAA8Y/pp9cn6H423Y/s1600/2014122900004.png" alt="" border="0" />

Please Follow AWE Workflow Other 4 Parts.

  1. Part 1 – Contains Record , Component , Pages & Menu Creation ( Create A Simple AWE PeopleSoft )
  2. Part 2 – Contains AWE Transaction Registration , Configuration , Approval Process & Generic Template Setup in thru PeopleSoft Portal ( Create A Simple AWE PeopleSoft Part – 2 )
  3. 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:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值