I have a requirement where I am getting the data in XML payload through PI in a proxy method for a single line item. I need to create PO, GR and Invoice using this data. The requirement is that either all should be completed successfully or none should be committed. How can this be achieved using BAPIs or is there any alternative to do the same?
How can the BAPIs be cascaded?
BAPI_PO_CREATE1 -> PO gets created
if successful : BAPI_GOODSMVT_CREATE -> GR done for the PO created (FAIL - return and rollback PO)
if GR is successful : BAPI_INCOMINGINVOICE_CREATE -> IV done (FAIL - return and rollback GR and PO)
If Invoice is created successfully, we need to commit all the results, Else nothing should be committed.