The following blog post is relevant only for SAP S/4HANA Cloud Public Edition. Please note that Developer Extensibility is required.
Use case:
You are trying to cancel a Billing Document in SAP S/4HANA Public Cloud, but the system prevents it with the error message “Document XXXXXXXX: Unable to cancel document; Cancel related eDocument first”. Alternative Use Case could be, that the cancellation of a billing document is allowed, but you want to further restrict it.
Important Warning:
This BAdI should only be used for special case handling allowing the cancellation or if you want to further restrict the cancellation. Please understand the country process in detail before overwriting standard country logic with the BAdI. If for example an eDocument is submitted and accepted by the authority, an invoice cancellations is often not allowed – the correction then has to be done with an additional document like credit memo or an additional invoice. Please keep also in mind that using this BAdI method can lead to inconsistent business data in your system – e.g. accepted eDocument with cancelled invoice. In many country implementations it is allowed to cancel the billing document, when the eDocument is in cancelled state or you were able to delete the eDocument.
Implementation:
To implement the above requirement method “if_edoc_adaptor_cloud~restrict_cancel” in BAdI EDOC_ADAPTOR_CLOUD (enhancement spot ES_EDOCUMENT_CLOUD). The method “restrict_cancel” receives the edocument data in the importing parameter “is_edocument” and source key and source type. The changing parameter “cv_restrict” allows you to control whether the electronic document can be cancelled or not – the value which is handed over is the determined value by standard.
Implementation Steps:
- Create implementation for enhancement spot ES_DOCUMENT_CLOUD.
- Create BAdI implementation for EDOC_ADAPTOR_CLOUD.
- (Optional) Create BAdI Filter for Country and/or Generic Filter.
- Create implementing class for BAdI EDOC_ADAPTOR_CLOUD, which implements the interfaces “if_badi_interfaces” and “if_edoc_adaptor_cloud”.
- Implement method “is_relevant” of interface “if_edoc_adaptor_cloud” in your BAdI class.
- Activate your BAdI implementation.
IF <your condition>.
cv_restrict = abap_true/abap_false.
ENDIF.
ENDMETHOD.
Source link
