Skip to Content

PBF how-to guide to use Approvers based on Fund Centers in Stage Workflow

This how-to guide is applicable for SAP Public Budget Formulation releases 8.1+ and describes how Approvers can be maintained using other header dimensions, or even custom attributes, along with necessary business logic to ensure that these Approvers are used in the PBF Stage Workflow.


The PBF Stage Workflow Admin screens allow users to maintain Approvers based on either Form Id-Stage combination or Form Definition-Stage combination. The following steps describe how Approvers can be maintained at the Fund Center-Stage level and the data structures, RFCs and VC Model changes required to achieve this.

1. Data Structures

Create a data structure to map Fund Centers and Stages to the corresponding Approvers. As an example, refer to following screen capture that shows a table ZPBF_FUNDCT_APPR with key fields as Fund Center and Stage.

To maintain Approvers in this table you could use the Table Maintenance generator to create a maintenance view or create custom VC screens just like other screens in Workflow Admin screens.

2. RFCs

Create a Custom RFC (let’s call it ZPBFWF_FUNDCT_APPROVER) that will accept Form Id and Stage and do the following:
1. Get Fund Center of the given Form instance
2. Get Approvers from a custom Fund Center-Approver table for a given Fund Center-Stage combination
3. Update table /PBFBI/WF_IS_APP with the Approvers found in step 2 using RFC /PBFBI/WF_APP_IS_SAVE.


Here is an example of very simple code that contains the core parts of the algorithm explained above.


FUNCTION ZPBFWF_FUNDCT_APPROVER.
*"--------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(IV_FORM_ID) TYPE  /PBFBI/FORM_ID
*"     VALUE(IV_STAGE) TYPE  /PBFBI/DE_STAGE
*"  EXPORTING
*"     VALUE(RETURN) TYPE  BAPIRET2
*"--------------------------------------------------------------------

  DATA ls_fundct_appr TYPE ZPBF_FUNDCT_APPR.
  DATA lt_approver TYPE /PBFBI/WF_IS_APP_TT.
  DATA ls_approver LIKE LINE OF lt_approver.
  DATA lv_fund_ct type /pbfbi/de_fund_ct.

  "Get Fund Center for given Form Instance
  SELECT SINGLE fund_ctr_id
    FROM /pbfbi/bform
    into lv_fund_ct
    WHERE form_id = iv_form_id.
  IF sy-subrc <> 0.
    EXIT.
  ENDIF.

  "Get Approvers for given Fund Center/Stage combo
  SELECT SINGLE *
    FROM ZPBF_FUNDCT_APPR
    INTO ls_fundct_appr
    WHERE fund_ct = lv_fund_ct
    AND stage = iv_stage.
  IF sy-subrc eq 0.

    "Build lt_approver table
    ls_approver-stage = iv_stage.
    ls_approver-approver1 = ls_fundct_appr-approver1.
    ls_approver-approver2 = ls_fundct_appr-approver2.
    INSERT ls_approver INto TABLE lt_approver.

    "Update Approver in Form-Id/Stage table
    CALL FUNCTION '/PBFBI/WF_APP_IS_SAVE'
      EXPORTING
        IT_APPROVER = lt_approver
        IV_FORM_ID  = iv_form_id.
  ENDIF.

ENDFUNCTION.


3. Front-end (VC Changes)

Change the AdvanceStage model in your custom forms to call the newly created RFC right before /PBFBI/WF_STAGE_ADVANCE is called. This would ensure that the Approvers for the given Form Id are updated from the table that maps Fund Centers to their corresponding approvers. Refer to following screenshots that indicate where the new RFC should be added.


Before



After

Conclusion

Thoroughly test your custom logic to ensure that Approvers are updated based on the newly created Fund Center-Stage Approver table. If an entry is missing in this table, the logic will look for Approvers maintained at Form Definition-Stage combination, and if none are found then Stage Advance RFC will return an error saying ‘Please maintain an active approver’. Feel free to ask questions in the comments section down below.

Former Member