Custom logic for Payment Files
SAP delivers several payment file structures with the Best Practices, but there is usually the case of a bank that requires some specific field or logic. There is also the possibility that the customer is using an existing data field (master or transactional data), for a specific process that might not be covered by the standard FPAY* structure, generated during the payment run.
With the introduction of BAdI FBL_EVENT_06 – Payment Medium: Custom Additional Reference Fields S/4HANA Cloud payment structures can be enhanced with a set of reference fields, read directly from an existing CDS View.
A set of pre-defined structure fields can be found in FPAYHX structure, and can be directly defined as the source structure field, in the mapping procedure:
So, how are the ZREF## fields populated? In the below step-by-step guide, you will get a general idea.
1. 1. A CDS view has to be selected having in mind 2 things:
a. The required source field is available in that CDS view.
b. The CDS view has a key field that “connects” to the payment information. The system must be able to do the selection from this CDS view, using a common field or information, present in both the FPAY* structure and the CDS itself.
2. 2. Custom logic has to be activated, using ABAP code (example provided below).
3. 3. Payment file structure updated, referencing the selected ZREF## field in step 2.
1 CDS View selection:
Access the “Custom CDS Views” App and search for the desired CDS View:
In this example, the CDS View i_supplier has the field that we need to add as a ZREF## field in the payment file structure, and also has a key field that can serve as the connection between this CDS View and the FPAY* structure, so that the system is able to do the correct selection.
2 Custom logic activation and example code:
Access “Custom Fields and Logic” App and create a new Custom Logic implementation:
DATA: ls_suppl TYPE i_supplier.
SELECT SINGLE * FROM i_supplier INTO @ls_suppl WHERE supplier = @paymentdata-gpa1r.
IF sy-subrc = 0.
paymentcustomerfields-zref01 = ls_suppl-TaxNumber1.
In yellow: selection of the CDS View (i_supplier)
In green: select to input CDS View fields into a temporary BADi structure
In blue: connection between payment structure and selected CDS View
In red: selection of CDS View field into one of the ZREF## fields, which will then be available for selection in the payment file structure. (Please note that in this example, TaxNumber1 is the name of the CDS View field, that can be checked in the CDS itself.)
Custom logic can now be activated and will be called during file creation, in the automatic payment process.
3 Structure update with ZREF## field selection
Now that the system will select the relevant data to be imputed into the selected ZREF## field, DME structure for the payment file can be updated in SSCUI 100558:
In the desired node, a source can now be selected for ZREF##:
Very good information Antonio! Thanks!!
Thanks for sharing, very useful tips!
Hi Antonio Moreira Rato
Good One. Thanks for sharing.
Great document.....Antonio. 🙂 Thanks.
Thanks for sharing Antonio. Very helpful info!
Great blog Antonio Moreira Rato! Thank you for sharing.
A Good reference Document for sure! Thanks for sharing Antonio Moreira Rato
Thank you for the content!
We appreciate your effort.
Is it possible to fetch the VAT amount of supplier invoice and display in this ZRef field of payment format?