Re-Integrate Report
Report ZFI_BILENDO_IMPORT_V2 for writing field values back from Bilendo to SAP.
Overview
| Property | Value |
|---|---|
| Report | ZFI_BILENDO_IMPORT_V2 |
| SAP module | FI-AR |
| Version | 2.1 |
| Function | Reads CSV files provided by Bilendo and writes field values (credit limit, dunning level, etc.) back to SAP master and transaction data |
| Includes | ZFI_BILENDO_IMPORT_F01 |
| Dependency | ZCL_FI_BILENDO_ASSIST_V2 (→ 03 - Assist Class) |
| Optional | This report is only required if you want to enable the bidirectional integration (Bilendo → SAP). |
Bilendo-Side Files
The report processes five predefined file types that Bilendo provides on the SFTP server:
| Parameter | Default file name | Content | SAP target |
|---|---|---|---|
| P_C_INFO | bilendo_credit_informations | Credit ratings | DBRTG (rating), date |
| P_C_LIM | bilendo_credit_limits | Credit limits | KLIMK (limit), CTLPC (risk class) |
| P_SEC | bilendo_securities | Insurance obligo | VLIBB (Ins. limit) |
| P_CUST | bilendo_customers | Customer master data changes | MAHNS, MANSP, MADAT, VLIBB |
| P_JOURN | bilendo_journal_entries | Document changes | MANST, MANSP, MADAT (at document level) |
Selection Screen
| Parameter | Type | Default | Description |
|---|---|---|---|
| P_C_INFO | Text255 | bilendo_credit_informations | File name for credit information |
| P_C_LIM | Text255 | bilendo_credit_limits | File name for credit limits |
| P_SEC | Text255 | bilendo_securities | File name for insurance obligo |
| P_CUST | Text255 | bilendo_customers | File name for customer master data changes |
| P_JOURN | Text255 | bilendo_journal_entries | File name for document changes |
| P_DIR | Text255 | /usr/sap/<SID>/COMM/Bilendo_IN/ | Inbound directory (set automatically) |
| P_DELETE | Checkbox | – | Delete processed files after import |
Source Code
Main Report – ZFI_BILENDO_IMPORT_V2
*&---------------------------------------------------------------------*
*& Report ZFI_BILENDO_IMPORT_V2
*&---------------------------------------------------------------------*
* Owner: Bilendo GmbH
* Short functional description: Import of FI document changes and
* master data write-back from the Bilendo platform
*----------------------------------------------------------------------*
REPORT zfi_bilendo_import_v2 MESSAGE-ID zfi.
TABLES: bkpf, bseg.
DATA: gt_seltab TYPE TABLE OF rsparams,
gt_seltab_255 TYPE TABLE OF rsparamsl_255,
gf_file TYPE string,
gf_file_kna1 TYPE string,
gf_file_bseg TYPE string,
gf_file_bsid TYPE string,
gf_file_bsad TYPE string,
go_bilendo TYPE REF TO zcl_fi_bilendo_assist_v2,
gf_msg TYPE string,
gt_t001 TYPE TABLE OF t001,
gs_t001 TYPE t001,
gf_cust_info TYPE text255,
gf_cust_limit TYPE text255,
gf_securities TYPE text255,
gf_customers TYPE text255,
gf_journal TYPE text255.
CONSTANTS: gc_dir_hed TYPE string VALUE '/..../Bilendo_IN/', " ← adjust for DEV
gc_dir_heq TYPE string VALUE '/..../COMM/Bilendo_IN/', " ← adjust for QA
gc_dir_hep TYPE string VALUE '/..../Bilendo_IN/'. " ← adjust for PRD
PARAMETERS: p_c_info TYPE text255 DEFAULT 'bilendo_credit_informations',
p_c_lim TYPE text255 DEFAULT 'bilendo_credit_limits',
p_sec TYPE text255 DEFAULT 'bilendo_securities',
p_cust TYPE text255 DEFAULT 'bilendo_customers',
p_journ TYPE text255 DEFAULT 'bilendo_journal_entries',
p_dir TYPE text255,
p_delete TYPE xfeld.
INITIALIZATION.
CONCATENATE '/usr/sap/' sy-sysid '/COMM/Bilendo_IN/' INTO p_dir.
AT SELECTION-SCREEN OUTPUT.
START-OF-SELECTION.
gf_cust_info = p_c_info.
gf_cust_limit = p_c_lim.
gf_securities = p_sec.
gf_customers = p_cust.
gf_journal = p_journ.
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
curr_report = sy-repid
TABLES
selection_table = gt_seltab
selection_table_255 = gt_seltab_255.
CREATE OBJECT go_bilendo
EXPORTING
it_seltab = gt_seltab_255.
" 1. Search for files in the directory
CALL METHOD go_bilendo->get_files.
" 2. Read and parse CSV files
CALL METHOD go_bilendo->read_csv( ).
" 3. Change credit limit and risk category
DATA: ls_credit_info TYPE go_bilendo->ty_s_credit_info,
ls_credit_limit TYPE go_bilendo->ty_s_credit_limit,
ls_customer TYPE go_bilendo->ty_s_customer,
ls_securities TYPE go_bilendo->ty_s_securities,
ls_journal TYPE go_bilendo->ty_s_journal.
CALL METHOD go_bilendo->credit_limit_change
EXPORTING
is_credit_info = ls_credit_info
is_credit_limit = ls_credit_limit.
" 4. Perform customer master changes
CALL METHOD go_bilendo->customer_change.
" 5. Perform document changes
CALL METHOD go_bilendo->doc_change
EXPORTING
is_journal = ls_journal.
" 6. Optional: Delete processed files
IF p_delete = 'X'.
go_bilendo->delete_files( ).
ENDIF.
INCLUDE zfi_bilendo_import_f01.Include F01 – Assembling the File Name
*----------------------------------------------------------------------*
* Include ZFI_BILENDO_IMPORT_F01
*----------------------------------------------------------------------*
* Assembles the full path for the input files,
* based on the system ID (sy-sysid).
*----------------------------------------------------------------------*
FORM get_filenames
CHANGING pf_file TYPE text255.
CONDENSE pf_file.
CASE sy-sysid.
WHEN 'HED'.
CONCATENATE gc_dir_hed pf_file INTO pf_file.
WHEN 'HEQ'.
CONCATENATE gc_dir_heq pf_file INTO pf_file.
WHEN 'HEP'.
CONCATENATE gc_dir_hep pf_file INTO pf_file.
WHEN OTHERS.
ENDCASE.
ENDFORM.Processing Flow
flowchart TD
START[Report Start] --> FILES[get_files\nSearch for files in directory]
FILES --> CSV[read_csv\nRead and parse CSV files]
CSV --> CREDIT[credit_limit_change\nCredit limit + risk category]
CREDIT --> CUST[customer_change\nDunning level, dunning block, ins. exposure]
CUST --> DOC[doc_change\nDunning level/date at document level]
DOC --> DEL{P_DELETE = X?}
DEL -->|Yes| DELETE[delete_files\nClean up files]
DEL -->|No| DONE[End]
DELETE --> DONECustomization Notes
Directory Paths
The paths must be adapted to your system landscape:
" Im Report:
INITIALIZATION.
CONCATENATE '/usr/sap/' sy-sysid '/COMM/Bilendo_IN/' INTO p_dir.
" Im F01-Include:
CONSTANTS: gc_dir_hed TYPE string VALUE '/usr/sap/DEV/Bilendo_IN/', " ← anpassen
gc_dir_heq TYPE string VALUE '/usr/sap/QA/COMM/Bilendo_IN/', " ← anpassen
gc_dir_hep TYPE string VALUE '/usr/sap/PRD/Bilendo_IN/'. " ← anpassenSystem IDs
The WHEN branches in F01 use the system IDs HED/HEQ/HEP. You must change these to match your actual system IDs.
Authorizations for Write-Back
The methods credit_limit_change, customer_change, and doc_change use BAPIs or direct table changes. The executing user (SM36 job user) needs the following:
| Authorization Object | Description |
|---|---|
| F_KNA1_BED | Change customer master |
| F_KNB1_BED | Change customer master (company code) |
| F_BKPF_BUK | Company code access FI |
| S_DATASET | File access on application server |
Error Handling
The assist class contains a send_email method that sends a notification if errors occur during write-back. This happens automatically in the following cases:
Failed credit limit changes (BAPI return errors)
Failed customer master changes
Failed document changes
The email configuration is set up within the class (→ 03 - Assist Class, method send_email).