Skip to Content
Technical Articles
Author's profile photo Niveditha Reddy AMMIREDDY

Approver change when Employee submit his leave request in Standard Leave Request Application


This Blog is about to how to change the approver change if an employee submit his Leave Request using standard Fiori Leave Request Application. In my requirement, we need to change the approver when employee request his leave request.

Below are the steps we followed and able to achieve the requirement as required.

First we need to know the standard BADI which it is triggered by the time of  request. PT_GEN_REQ is the standard BADI is the one which we need to enhance for custom changes.

Go to SE19, provide the Enhancement spot as “PT_GEN_REQ” and click on create.

Provide the Enhancement Implementation name as starting with Y/Z (Ex: zbadi_approver) and provide the short text as “Badi for Approver”, then click on OK button and save it in object directory entry.

Provide the Badi Implementation as ZXX_XX and Implementation Class as ZCL_XX and select the drop down as PT_GEN_REQ in Badi defination, then save it in Object Directory Entry.

Check the Default Implementation check box and save and activate it.

Now click on Implementing Class and double click on method IF_EX_PT_GEN_REQ~CHECK_SELECTED_NEXT_PROCESSOR, then click on ok to implement the method.

Provide the below parameters as shown in below screenshot.

Now Implement the code as per the requirement.

DATA: lv_approver        TYPE persno,
      ls_persadata_tab   TYPE ptreq_actor_struc_flat,
      lt_persadata_tab   TYPE ptreq_uia_approver_tab,
      lt_persadata_final TYPE ptreq_uia_approver_tab.

lt_persadata_tab[]  = im_persadata_tab[].
REFRESH im_persadata_tab.

lv_approver  = '12345678'.
** Note - for you reference here you can add the logic for your requirement and map the approver name to
** lv_approver

LOOP AT lt_persadata_tab INTO ls_persadata_tab.
  IF lv_approver IS NOT INITIAL.
    ls_persadata_tab-pernr = lv_approver.
    ls_persadata_tab-objid = lv_approver.
  APPEND ls_persadata_tab TO lt_persadata_final.
  CLEAR ls_persadata_tab.

im_persadata_tab[] = lt_persadata_final[].

Leave Request notification will send to the newly added Approver’s Inbox when an employee applies the leave request.

I hope this Blog might help you. Thank you…

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.