Symptom
You want to know how to use class CL_SDBIL_ACCTGINF_BPD_RTME_DTA (Read Transient Billing Doc. on Call to Accounting Interface) in custom logic (that is, in BAdIs implemented via key user extensibility) to retrieve transient billing document data.
Environment
SAP S/4HANA Cloud Public Edition
Resolution
When a billing document is posted to financial accounting, specific financial accounting BAdIs can call class CL_SDBIL_ACCTGINF_BPD_RTME_DTA (Read Transient Billing Doc. on Call to Accounting Interface) to retrieve transient data from both header and item level of the document. This allows the custom logic in your BAdI implementation to evaluate this data and perform specific actions at the time of billing document posting, when the billing document may not be saved in the database yet.
You can use this class in implementations of the following BAdIs:
- FIN_ACDOC_HEADER_SUBSTITUTION - Journal Entry Header Substitution
- FIN_ACDOC_ITEM_SUBSTITUTION - Journal Entry Item Substitution
- FIN_ACDOC_SUBSTITUTION - Journal Entry Substitution
Note that these BAdIs are not billing-specific, they can also be called in the context of other scenarios. In your implementation, filter for relevant scenarios to restrict your implementation to the relevant use cases. For example, use custom logic to check whether accountingdocheader-accountingdocumenttype = 'RV' .
Also note that some BAdI calls from billing to financial accounting may not actually contain a billing document number as input. Therefore, always ensure that the field containing the document number of the target billing document is not initial.
Constraints
Please note the following constraints when using this class:
- You cannot use this class in implementations of the following BAdIs, as no data will be returned:
- SD_BIL_DATA_TRANSFER (Custom Data Transfer for Billing Process Documents)
- FIN_ACDOC_EXT_CHG_SUBSTITUTION (Journal Entry Item Extension Fields Substitution For Change)
- You can only use this class in the context of financial accounting.
The class cannot return data for billing process documents that can't be posted to financial accounting (such as preliminary billing documents). - Currently, you cannot use this class to retrieve the transient data of invoice lists.
Class Methods
The class contains the following two methods:
- IF_SDBIL_ACCTGINF_BPD_RTME_DTA~GET_BILLING_DOCUMENT
- IF_SDBIL_ACCTGINF_BPD_RTME_DTA~GET_BILLING_DOCUMENT_ITEMS
The only input parameter per method is the document number of the billing document being posted. This parameter is always mandatory.
Posting of Saved vs Not-Yet-Saved Billing Documents
When a billing document is posted to financial accounting, the class can always return its transient data. It returns transient data independently of whether or not the billing document is already saved in the database at the time of posting.
Error Handling
When there is a problem in data access, no data is returned. For example, if the number of the billing document for which you request transient data differs from the number of the billing document currently being posted, no data is returned.
We recommend that you carefully consider how to handle empty return data in your custom logic.
Reading Custom Fields
The class can also retrieve the values of custom fields. This requires that these custom fields are enabled and published at header or item level in the corresponding CDS view:
- I_BILLINGDOCUMENT (Header)
- I_BILLINGDOCUMENTITEM (Item)
Key users can use the Custom Fields app to enable custom fields for these CDS views.
In the app, these CDS views are listed on the APIs tab. For each view, choose Enable Usage and publish the change.
Finality and Completeness of the Retrieved Data
Because posting has started but is not yet completed when the BAdI is called, some field values may not be final or up to date at the time of data retrieval. Some billing document header fields may be empty or contain values that are no longer valid. Examples of the affected fields include:
- ACCOUNTINGTRANSFERSTATUS and other status fields are not reliably set yet.
- PRICINGDOCUMENT is not yet final.
- FISCALYEAR and ACCOUNTINGDOCUMENT are not filled with values yet.
Custom Logic Example
The following code snippet shows an example implementation of the class via the FIN_ACDOC_HEADER_SUBSTITUTION BAdI.
MOVE-CORRESPONDING accountingdocheader TO accountingdocheaderout.
IF accountingdocheader-accountingdocumenttype = 'RV' AND accountingdocheader-originalreferencedocument IS NOT INITIAL.
DATA(bd_head) = CL_SDBIL_ACCTGINF_BPD_RTME_DTA=>create_instance( )->get_billing_document( accountingdocheader-originalreferencedocument(10) ).
DATA(bd_items) = CL_SDBIL_ACCTGINF_BPD_RTME_DTA=>create_instance( )->get_billing_document_items( accountingdocheader-originalreferencedocument(10) ).
IF bd_head IS NOT INITIAL AND bd_head-soldtoparty = '0010100003'.
accountingdocheaderout-accountingdocumentheadertext = 'BillingDocument based'.
substitutiondone = abap_true.
ENDIF.
ENDIF.
Note that in the above example, both header and item data is retrieved, but only header data is evaluated.
Related Information
For more information about the BAdIs for journal entry substitution, see Business Add-Ins for Substitutions for Journal Entries on SAP Help Portal.
Keywords
journal entry substitution, Sales Billing, CL_SDBIL_ACCTGINF_BPD_RTME_DTA, class, transient billing document data, billing document posting , KBA , SD-BIL-2CL , Billing (Public Cloud) , FI-GL-2CL , General Ledger Accounting (Public Cloud) , How To
SAP Knowledge Base Article - Public