SAP Knowledge Base Article - Public

3089559 - Use of BAdI MM_PUR_S4_PO_OPEN in Purchase Order

Symptom

Purchase Orders are not released after the Open BAdI is implemented. Once the BADI MM_PUR_S4_PO_OPEN is implemented and active the PO can't be updated by system users on technical processes like Workflow.

Environment

SAP S/4HANA Cloud Public Edition

Reproducing the Issue

  1. BAdI MM_PUR_S4_PO_OPEN is implemented.
  2. Purchase order stays 'In approval', while approver has already released.

Resolution

The BAdI MM_PUR_S4_PO_OPEN is used to put a purchase order in display mode and make further processing of the purchase order impossible. The following parameters are provided:

  • ISREADONLY

  • ISVALID

When opening an existing purchase order, the

default value for ISREADONLY = false → The purchase order is valid.

Change value for ISREADONLY = true → The purchase order is in read only mode and cannot be edited.

When opening an existing purchase order, the

default value for ISVALID = abap_true → The purchase order is valid.

Change value for ISVALID = abap_false → The purchase order is not valid. It is impossible to continue processing the document.

The BAdI can be activated by specifying the affected single CB users like in the example below:

*****************
  METHOD if_mm_pur_s4_po_open~open.

*     If sy-uname eq "CBXXXXXXXXXXX"

*     In case you want to switch the purchase order to READ-ONLY mode, parameter ISREADONLY needs to be set.
*     isreadonly = abap_true.

*     In case you want to hide the purchase order data, parameter ISVALID needs to be cleared:
*     isvalid = abap_false.
*   ENDIF.

   ENDMETHOD.

In case you don´t specify the logic for selected CBusers, you need to exclude the System users like in the example code below:

*****************
  METHOD if_mm_pur_s4_po_open~open.

*  Be aware to exclude technical processes like Workflow etc. from this setting, otherwise this processes are impacted!
*   If sy-uname <> 'Your WFL Usr' AND         "Workflow User
*      sy-uname <> 'any tec. Usr'.            "other technical user which should be excluded

*     In case you want to switch the purchase order to READ-ONLY mode, parameter ISREADONLY needs to be set.
*     isreadonly = abap_true.

*     In case you want to hide the purchase order data, parameter ISVALID needs to be cleared:
*     isvalid = abap_false.
*   ENDIF.

   ENDMETHOD.

Note:

In case you receive the error message: "Access to the field 'SY-UNAME' IS NOT PERMITTED IN THE RESTRICTED LANGUAGE SCOPE"

Use following statement:

Data(lv_name) = cl_abap_context_info=>get_user_technical_name( ).

If LV_NAME <> 'SAP_WFRT'

Disclaimer: Code for BADI implementation is out of SAP Product scope and responsability

Keywords

Open BAdi, MM_PUR_S4_PO_OPEN, S4HC, S4_PC, S4_1C, X4BC, Purchase Orders, Badi implementation, in approval, workflow cannot be executed, MM-PUR-PO, me21n , KBA , MM-FIO-PUR-PO-2CL , Fiori UI for Purchase Orders (Public Cloud) , MM-PUR-PO , Purchase Orders , Problem

Product

SAP S/4HANA Cloud 2005 ; SAP S/4HANA Cloud 2108 ; SAP S/4HANA Cloud 2111 ; SAP S/4HANA Cloud 2202 ; SAP S/4HANA Cloud 2208