Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Bohdan
Active Contributor
Hello SAPers !

My previous post focused on the baseline process around import of bank statements in Fiori. This post explores additional enhancements that are necessary if you want to upload bank statements in bank specific formats e.g., XML, CSV, JSON etc.

Introduction


If your bank does not provide bank statements in a commonly recognized format (e.g., MT940, Multicash, BAI etc.), you can configure SAP to upload bank statements in any structured format. I’ve started exploring this topic in my previous posts and recommend checking them out. Configurations described in those posts are technical pre-requisites and will provide a good starting point for this post. The links to these posts are provided below:

This post will describe how to upload a bank statement in CSV format, but it will focus on Fiori-specific settings & enhancements. However, the idea can be applied to bank statement in any structured i.e., machine-readable format.

This post does not describe the parsing logic for CSV file or how the resulting data should be mapped against standard SAP tables that store transactional details of bank statements. These details were described in separate post mentioned above.

Four separate enhancements (i.e., BADIs) are required before you can upload such bank statements to SAP. Two of these enhancements are specific to Fiori. One of these enhancements checks if the bank statement file is compliant with the list of configured formats. Another one – calculates the number of bank statements in the file. Two more enhancements are executed in backend and were described in my earlier post.



Baseline configuration of new bank statement format


Define new bank statement format in view VFIEB_MAPP_XCTRL. You can also use the following menu path for this configuration activity:

SPRO → Financial Accounting → Bank Accounting → Business Transactions → Payment Transactions → Electronic Bank Statement → XML Format and Bank-Specific Formats.


Configure new bank statement format for upload of bank statement. Use the following menu path to configure the format. Alternatively, you can use t-code S_ER9_11000399 or maintenance view VC_FAR_IPF (via SM34) to configure it.

SPRO → Financial Accounting → Bank Accounting → Business Transactions → Payment Transactions → Electronic Bank Statement → Configure Formats for Import (SAP Fiori).


Essentially, you define a new bank-specific bank statement format (value “X” in drop-down list stands for bank-specific format) and link it to the format defined earlier (i.e., in view VFIEB_MAPP_XCTRL). Entry UA_PRV in the configuration represents the transaction type (i.e., t-code OT83) that will be used for derivation of posting rules.


Configure a new parameter set to control the processing parameters for import of bank statement. You can use t-code S_ER9_11001563 or maintenance view VC_FAR_BSIMP_PSETS (via SM34) to configure it. Relevant configuration activity is also available under the following menu path:

SPRO → Financial Accounting → Bank Accounting → Business Transactions → Payment Transactions → Electronic Bank Statement → Define Parameter Sets.


Apart from these configuration activities, implement BADIs FIEB_GET_BANK_STMTS_X & FIEB_MAPPING_X as described in my previous post.

Fiori-specific enhancements for custom bank statement format


If you maintained baseline configuration for custom bank statement format as described above, you can attempt to upload bank statement via Fiori App F1680Manage Incoming Payment Files”. However, the app will throw an error message “No implementation was selected for the current BAdI. An exception was raised”. Unfortunately, the error message does not provide further details e.g., what BAdI was not implemented.


Implement BADI FAR_IPF_FORMAT_RECOGNITION to address this exception. The filter value for this enhancement should be the same as configured in view VFIEB_MAPP_XCTRL.


Sample source code for the BADI:



  method if_far_ipf_badi_formats~is_compliant_format.

data lv_bank_statement type string.
call function 'LXE_COMMON_XSTRING_TO_STRING'
exporting
in_xstring = iv_bank_statement
importing
ex_string = lv_bank_statement
exceptions
error = 1
others = 2 .

if sy-subrc <> 0.
return.
endif.

split lv_bank_statement at cl_abap_char_utilities=>cr_lf into table data(lt_csv_lines).
if sy-subrc = 0.
rv_is_compliant = abap_true.
endif.

endmethod.

Implement the second BADI FAR_IPF_NUMBER_OF_STATEMENTS to calculate the number of bank statements per payment file. Note this BADI uses combination of two values for the filter purposes:
- FILE_FORMAT should be “X” (i.e., bank specific format as explained above).
- Format ID from view VFIEB_MAPP_XCTRL should be indicated as FILE_FORMAT_LONG.


Personal opinion: I was a bit confused by these BADI filters and do not fully understand why SAP uses different filter values for these two BADIs. But at least it is working as advertised.

Depending on the complexity of your bank statement, you can implement this BADI differently. If your bank always provides only one bank statement per file, the logic of this BAdI will be very easy:
  method if_far_ipf_badi_statements~get_number_of_statements.
rv_number_of_statements = 1.
endmethod.

However, if you bank provides more than one bank statement per file, you will need to implement more complicated logic. Here is a baseline source code that allows you to fetch the binary data of the payment file and transform it into a text table. Once you have a text table, you can implement your own logic to parse it and decide how many statements it contains.
  method if_far_ipf_badi_statements~get_number_of_statements.

data:
lt_contents_hex type far_ipf_tt_contents_hex,
ls_document_data type sofolenti1,
lt_text type table of char255,
lv_string type string.

data(lo_so_service) = cl_far_ipf_so_service=>get_so_service( ).

try.
lo_so_service->so_document_read(
exporting
iv_document_id = iv_document_id
importing
es_document_data = ls_document_data
changing
ct_contents_hex = lt_contents_hex ).
catch cx_far_ipf_exception.
return.
endtry.

if lt_contents_hex is initial.
return.
endif.

call function 'SCMS_BINARY_TO_TEXT'
exporting
input_length = conv i( ls_document_data-doc_size )
tables
binary_tab = lt_contents_hex
text_tab = lt_text.

" Implement your logic here
" Analyze the text in table lt_text and calculate the number of statements
" Return the number of statements via rv_number_of_statements

endmethod.

Upload of custom bank statement in Fiori


Use Fiori App F1680Manage Incoming Payment Files” to upload bank statement. Select the option “Bank Statement”:


Note: this post is based on the App version 8.0.1.

Select the format for bank statement in CSV & a dedicated parameter set. Drag & drop the payment file for upload or provide the file path via dialog menu. Start processing.


As you can see, the file was uploaded:


Detailed log for the uploaded file:


I hope you found some interesting insights in this post and am looking forward to your comments.

Regards,

Bohdan Petrushchak