Symptom
How to prevent billing creation when a custom field in billing document header is not maintained.
Environment
SAP S/4HANA Cloud Public Edition
Resolution
Use BAdI SD_BIL_DATA_TRANSFER to achieve this.
Refer to below code example:
* Mandatory step for all implementations:
* Copy the importing parameters to the changing parameters.
MOVE-CORRESPONDING bil_doc TO bil_doc_res.
MOVE-CORRESPONDING bil_doc_item TO bil_doc_item_res.
MOVE-CORRESPONDING bil_doc_item_contr TO bil_doc_item_contr_res.
* Check header custom field - if empty, reject the item
IF bil_doc-yy1_***(custom field name) IS INITIAL.
billingdocumentitemisrejected = abap_true.
billgdocitmrejectionreasontext = '*** is mandatory. Billing document cannot be created.'.
ENDIF.
See Also
- refer to: Business Add-Ins (BAdIs) for Sales Billing
- refer to: Custom Data Transfer for Billing Process Documents
- refer to: SAP Note 3599594 – How to make the fields mandatory in Billing Header data for Preliminary Billing Document in S/4HANA Public Cloud edition
- refer to: SAP Note 3227690 – Avoid empty Custom Fields on Sales Billing process flow
Keywords
billing document, header custom field, mandatory, validation, block creation, VF01, SD_BIL_DATA_TRANSFER, BAdI, sales billing, custom fields and logic, reject item, billing header, S/4HANA Cloud, data transfer BAdI, prevent creation , KBA , SD-BIL-IV-2CL , Processing Billing Documents (Public Cloud) , Problem
SAP Knowledge Base Article - Public