Skip to Content
Technical Articles
Author's profile photo Joe Dutra

Ariba Buying & Invoicing Service Entry Sheet Automatic Approval in SAP ERP with CIG

Problem statement

When a Service Entry Sheet (SES) is sent from Ariba Buying & Invoicing (B&I) to the SAP ERP (ECC or S/4) though the Ariba CIG adapter, the SES document is created in the ERP without acceptance. An end user must go in the SES document and manually Accept or Reject the SES in the ERP. At this moment a SES Status Update message is triggered, updating the SES document in B&I.
Customers using the SES approval workflows in B&I would prefer for the SES to be automatically approved in the SAP ERP after the approval happens in Ariba.

How to fix this?

Implement the following CIG AddOn BADIs on the SAP ERP.
The 1st BADI will change the Acceptance flag on the incoming SES message, so the SES document on the SAP ERP will be created as Approved for all SES coming from B&I.
The 2nd BADI will trigger an SES Status Update message back to B&I changing the SES Status in B&I from “Awaiting External Approval” to “Processed”. This will also make the SES Response go back to the Supplier on the Ariba Network updating the SES status there.

Prerequisites

  1. CIG AddOn is on version SP08 or greater.
  2. The connectivity between the SAP ERP, CIG and B&I functional
  3. All configurations for the Service Entry Sheet are configured and tested on the SAP ERP
    • SPRO activity: SAP Ariba Cloud Integration Gateway -> SAP Ariba Procurement Integration -> Application Specific Settings -> Service Entry Sheet

Implement BADI ARBCIG_SES_CREATE

Create an implementation for BADI ARBCIG_SES_CREATE (Enh. Spot ARBCIG_ES_SES_CREATE).
Implement the Method IF_ARBCIG_SES_CREATE~UPDATE_SES_BAPITABLES and add the following code.

* Making B&I SES auto accepted in ECC.
    CS_ENTRYSHEETHEADER-ACCEPTANCE = 'X'.

Note that if you want to include additional criteria for making certain SES to get Auto-approved and others to be approved on SAP ERP, you can do so in this Method.
This BADI is only executed when a SES is received from Ariba B&I application. It won’t affect SES coming directly from Ariba Network to the SAP ERP (Commerce Automation).

Implement BADI ARBCIG_SESR_UPDATE

Create an implementation for BADI ARBCIG_SESR_UPDATE (Enh. Spot ARBCIG_ES_SESR_UPDATE).
Implement the Method IF_ARBCIG_EX_SESR_UPDATE~POST_CHANGE_SESR_DATA and add the following code.

* Implementation to send the Accepted status for Auto_accepted SES from B&I
    constants: lc_p2p_import_pull  TYPE arbcig_document_type_code  VALUE 'ServiceSheetImportPullRequest'.

    data: lv_realm_name   TYPE arbcig_realm_name,
          wa_p2p_resp     TYPE arbcig_resp_p2p,
          ls_auth_param   TYPE arbcig_authparam.

* Check if a B&I SESR was triggered. We won't do anything for AN SESR.
* Check if a successful message was sent back to B&I. We won't generate an Accept SESR for a failed SES.
* A successful B&I SESR message will always contain the SAP SES Number. A failed SESR back to B&I won't contain the SAP SES number.
    if SESR_P2P-header-sap_document_id is not initial.
      wa_p2p_resp = SESR_P2P.
* mark the SESR as Approved
      wa_p2p_resp-header-document_status = 'approved'.
* Get the B&I Realm name
      SELECT SINGLE * FROM  arbcig_authparam
                      INTO  ls_auth_param
                     WHERE solution  = 'AR' AND
                           is_parent = ''.
      lv_realm_name = ls_auth_param-realm.
* Call the SESR for the Approval message in ServiceSheetImportPullRequest
      CALL FUNCTION 'ARBCIG_SAP_RESPONSE_TO_P2P'
        EXPORTING
          transaction_type = lc_p2p_import_pull
          realm_name       = lv_realm_name
          header           = wa_p2p_resp-header
          return           = wa_p2p_resp-return.
    endif.

Note that that the above code is triggering an Accepted SES Status Update message back to Ariba B&I for any SES received from B&I. If you have additional criteria for making certain SES to get Auto-approved and others to be approved on SAP ERP, you also need to include this filter criteria here in this method.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Husain Dahodwala
      Husain Dahodwala

      Hi Joe,

      We are implementing a scenario where ERP initiated SES will be sent over to B&I and then to the suppliers via AN. The supplier will create the invoice based on the SES . We are facing few errors while doing this,

       

      1. For SES created for a service item based PO the SES is failing in CIG with below error.

      Ariba Network Response is :"Bad Request" and Error Code:"400" and Error Code Response:"Error:ServiceEntryItem 0000000010 has an invalid line number reference

      2. For SES created via a Limit PO , the SES flows successfully to B&I and then to the suppliers via AN. The supplier is able to create an invoice in AN from the SES submitted. The invoice is coming to B&I but the IR document is failing as the incoming Invoice cXML is missing the ERPServiceSheetID tag which is causing the S4 BAPI to throw error below . I dont know why it does not have the number.

      Can you please guide us on what could be the issue here?