Ansicht
Dokumentation

MMPUR_WORKFLOW_AGENT - Determination of Workflow Agents for Purchasing Documents

MMPUR_WORKFLOW_AGENT - Determination of Workflow Agents for Purchasing Documents

Addresses (Business Address Services)   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

This Business Add-In (BAdI) is used in Purchase Order Processing (MM-PUR-PO), Purchase Requisition Processing (MM-PUR-REQ), Purchase Contract Processing (MM-PUR-OA-CON) and Purchase Scheduling Agreement Processing (MM-PUR-OA-SCH), RFQ and Quotation Processing (MM-PUR-RFQ), Central Purchase Contract Processing (MM-PUR-HUB-CON), Service Entry Sheet Processing (MM-PUR-SVC-SES), Supplier Confirmation Workflow (MM-PUR-CNF-WFL) and is intended to be used in a Cloud edition only.

You can use this BAdI to implement your own workflow agent determination. If needed, you can access the purchasing document data. You can access the data by using the corresponding CDS views. Based on the document data, you can define a list of approvers. The import parameter PreviousApproverListprovides information about where you are in the workflow and helps you to determine the current approval level and the corresponding approvers.

To differentiate the BAdI implementations, the following filter conditions have to be used:

  • businessobject = PurchaseOrder
  • businessobject = PurchaseRequisition
  • businessobject = CentralPurchaseRequisition
  • businessobject = PurchaseContract
  • businessobject = SchedulingAgreement
  • businessobject = RequestForQuotation
  • businessobject = SupplierQuotation
  • businessobject = CentralPurchaseContract
  • businessobject = ServiceEntrySheet
  • businessobject = SupplierConfirmation

  • In the standard system, the BAdI is not active.
  • The BAdI is filter-dependent.

Method:The BAdI interface method is GET_APPROVERS.

Import Parameters:

The following import parameters are provided:

  • BUSINESSOBJECT This parameter provides the business object name (like PurchaseOrder, PurchaseRequisition or SupplierQuotation, etc.)
  • PURCHASINGDOCUMENT This parameter provides the purchasing document number
  • PURCHASINGDOCUMENTITEM This parameter provides the item number of purchasing document
  • WORKFLOWSCENARIO This parameter provides the information about which workflow scenario is used, as there can be several scenarios for the same business object
  • PREVIOUSAPPROVERLIST This parameter provides the approvers of the previous approval steps. It is needed to determine the current position in approval workflow. Please note that this list contains only the approvers who have approved the purchase requisition in the previous levels. The approvers corresponding to steps that have been skipped, are not included in this list.
  • TASKTYPE,,,,,,,,,,This parameter provides the information about the type of task in context of which the BAdI was invoked. This can take the values 'Approval' or 'Review' that correspond to the Workflow Stepsand Review Stepsrespectively, in the app Manage Workflows for .
  • STEPINFO This parameter provides the following information:
  • currentstep - The current step number. For example, consider there are 4 steps in the workflow. If the first step is completed, second step is skipped, and the recipient for the third step is "Agent Determination by BAdI", then the current step level in STEPINFO (field STEPINFO-currentstep) is 3.

  • totalsteps - The total number of steps in the workflow

  • stepsdetails - A table containing the step number, skip status and the rule type. The skip status tells us if the step has been skipped or not, and the reason why the step has been skipped. The skip status information is available up to the previous step. The rule type tells us about the type of the rule used for determining the recipient.

Please note that STEPINFO is an optional parameter, and is currently available ONLY for the business objects, "PurchaseRequisition", "CentralPurchaseRequisition", "PurchaseOrder", "CentralPurchaseContract", "PurchaseContract", and "SchedulingAgreement". Skip status is not applicable for purchase orders.

Change Parameter:

  • APPROVERLIST This parameter contains the approvers of the current approval level

Example Implementation:

lv_level = lines( previousapproverlist ).

** ----- Approval Level 1

IF lv_level = 0.

ls_badi_approver-businessuser = 'CB9980000943'.

ls_badi_approver-approvallevel = 1.

APPEND ls_badi_approver TO lt_badi_approver.

* ----- Approval Level 2

ELSEIF lv_level = 1.

ls_badi_approver-businessuser = 'CB9980000945'.

ls_badi_approver-approvallevel = 2.

APPEND ls_badi_approver TO lt_badi_approver.

* ----- Approval Level 3

ELSEIF lv_level = 2.

IF ( line_exists( previousapproverlist[ businessuser = 'CB9980000458' ] ) ).

ls_badi_approver-businessuser = 'CB9980000899'.

ls_badi_approver-approvallevel = 3.

APPEND ls_badi_approver TO lt_badi_approver.

ELSE.

ls_badi_approver-businessuser = 'CB9980000456'.

ls_badi_approver-approvallevel = 3.

APPEND ls_badi_approver TO lt_badi_approver.

ENDIF.

ENDIF.

Implementing the above piece of code does the following:

•,,The current approval level is determined with the help of the previous approver list

•,,Based on the approval level, the current approver is determined

•,,If current approval level is 1, approver is set as user 'CB9980000943'

•,,If current approval level is 2, approver is set as user 'CB9980000945'

•,,If current approval level is 3, the approver is determined based on whether user 'CB9980000458' was one of the previous approvers. If yes, the current approver is set as user 'CB9980000899', else the approver is set as user 'CB9980000456'.

/* This section of code containing "stepinfo" is relevant ONLY for the Business Objects, "PurchaseRequisition", "CentralPurchaseRequisition", "PurchaseOrder", "CentralPurchaseContract", "PurchaseContract", and "SchedulingAgreement". */

IF stepinfo-totalsteps = 3.
IF stepinfo-currentstep > 1.
lv_previousstep = stepinfo-currentstep - 1.
READ TABLE stepinfo-stepsdetails INTO DATA(ls_previousstepdetail) WITH KEY stepnumber = lv_previousstep.
IF sy-subrc EQ 0.
CASE ls_previousstepdetail-agentruletype.
WHEN 'FIXED_USERS'. " People Picker User
APPEND 'CB9980000568' TO approverlist.
WHEN 'BADI_RULE'. " Agent Determination by BAdI
IF ls_previousstepdetail-skipstatus EQ 'C'."Skipped as Step Conditions are not met
APPEND 'CB9980001448' TO approverlist.
ELSE.
APPEND 'CB9980000783' TO approverlist.
ENDIF.
WHEN 'AGENT_RULE'. "Roles(e.g. Manager of Workflow Initiator)
APPEND 'CB9980000878' TO approverlist.
WHEN 'TEAM_FUNCTION'."Teams created in Manage Teams & Responsibilities App ( Procurement )
APPEND 'CB9980000908' TO approverlist.
ENDCASE.
ENDIF.
ENDIF.
ENDIF.

Implementing the above piece of code does the following:

Based on the skip status and the agent rule type in the previous step details, the approver for the current step is determined.






General Data in Customer Master   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 9107 Date: 20240523 Time: 221334     sap01-206 ( 125 ms )