
How to Send Invoice status update for Canceled/Reversed invoice (MR8M) from ERP or S/4 HANA to SAP Ariba Business Network
From few customers to mostly all, a scenario would occur where when a supplier submits an invoice from Ariba Business Network and it is approved in ERP, still a need arises to Cancel or Reverse the fully Approved invoice in S/4 HANA. The reason can vary like late realization to change the Account assignment due to budget issues, manual mistakes by users, wrong invoice posted by supplier but it got approved etc. the reasons can be multiple based on customers scenario.
The manual reversal/cancellation of an invoice in ERP (Target system) can make the system out of synchronization from Ariba Business Network (Source system) if the accurate invoice status update is not sent for the cancellation/reversal action from ERP. The accurate status update re-creates the open commitment in both source and target system.
The challenge to send the status cancelled/Reversed invoice through standard program ARBCIG_INVOIC_STATUS_EXPORT persists as the program doesn’t pick the record for canceled/reversed invoice to send it to Ariba Business Network for 42K commerce automation scenario. SAP has not provided any parameter to handle Canceled/Reversed invoice neither have any BADI method which can send the Status update to Ariba Business Network from ERP.
However, the only supported use case to cancel the invoice in the ERP (target system) is if the invoice is created in the Business Network (Source system) and is reconciled in Ariba Buying and Invoicing. In this case, it will be possible to cancel the invoice on the ERP side and export the Canceled status through standard program ARBCIG_INV_STATUS_EXPORT.
But here, we will be specifically talking about the program ARBCIG_INVOIC_STATUS_EXPORT which send invoice status update to Ariba Business Network from S/4 HANA or ERP. So, Lets see how we can achieve this requirement with different approaches and its challenges.
Approach 1:
We have a Business Network API named as “Ariba Network Invoice Header DATA Extraction API”. The approach is to get the invoice details through a GET request for a specified date and write a custom logic in ABAP and call a POST HTTPS Method to update the Invoice status and Comments for canceled invoice. This could have been achieved within the standard program.
However, there is a restriction with Business Network API where only GET HTTPS request can be executed. This is same for all Business Network APIs. POST HTTPS request is not allowed.
Due to this restriction, we cannot achieve the requirement through API which could have been the most preferred way to fulfill this requirement.
Approach 2:
We can copy the entire standard program ARBCIG_INVOIC_STATUS_EXPORT and make a Z program and add the logic for cancellation invoice status and schedule a batch job for this custom program. However, this is not a very good approach as we will be losing all the important future correction Notes related to standard program which will be out of use.
Approach 3:
We will not touch the standard program ARBCIG_INVOIC_STATUS_EXPORT at all. The standard Program currently sends the relevant ISU to Business Network when invoice is Parked, deleted, Paid, approved in ERP.
Instead, we will copy the standard program and include the reversed/canceled logic and comment the logic for other status like Parked, Paid, Deleted, approved as it is already getting handled in standard program. The custom program should be scheduled for a Batch Job as it will send only delta records from last run date and time. However, we have to schedule with a frequency where always standard program will run first and after that the custom program batch job runs.
E.g. If Frequency for standard program is every 15mins then custom program can be scheduled for every hour.
Logic to find the reversed/cancelled invoice:
Tables to be used: RBKP, BSEG and CDHDR
Table RBKP: If Reversed by is NE Blank and Tcode = MR1M then canceled status should be sent for field BELNR
Additionally, in standard program, we maintain the date and time stamp for invoice status update in ISU BTE configuration and it gets saved in table ARBCIG_PRXYPARAM. This table stores the proxy parameters for ISU. Likewise, we need to create a custom table to maintain the time stamp for reversed/canceled invoice records.
In our case, we have maintained it in a custom table through SM30.
Custom Program Execution:
We tried to send the canceled status from S/4 HANA. However, the standard CIG is mapping the canceled status to Rejected. (Got reference of standard status mapping from CIG specs)
Thank you so much.
Please feel free to comment if you achieved it through a better approach than this. Also post your comments if there are any disagreements.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.