Re-Integrate Report

Report ZFI_BILENDO_IMPORT_V2 for writing field values back from Bilendo to SAP.

Overview

PropertyValue
ReportZFI_BILENDO_IMPORT_V2
SAP moduleFI-AR
Version2.1
FunctionReads CSV files provided by Bilendo and writes field values (credit limit, dunning level, etc.) back to SAP master and transaction data
IncludesZFI_BILENDO_IMPORT_F01
DependencyZCL_FI_BILENDO_ASSIST_V2 (→ 03 - Assist Class)
OptionalThis 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:

ParameterDefault file nameContentSAP target
P_C_INFObilendo_credit_informationsCredit ratingsDBRTG (rating), date
P_C_LIMbilendo_credit_limitsCredit limitsKLIMK (limit), CTLPC (risk class)
P_SECbilendo_securitiesInsurance obligoVLIBB (Ins. limit)
P_CUSTbilendo_customersCustomer master data changesMAHNS, MANSP, MADAT, VLIBB
P_JOURNbilendo_journal_entriesDocument changesMANST, MANSP, MADAT (at document level)

Selection Screen

ParameterTypeDefaultDescription
P_C_INFOText255bilendo_credit_informationsFile name for credit information
P_C_LIMText255bilendo_credit_limitsFile name for credit limits
P_SECText255bilendo_securitiesFile name for insurance obligo
P_CUSTText255bilendo_customersFile name for customer master data changes
P_JOURNText255bilendo_journal_entriesFile name for document changes
P_DIRText255/usr/sap/<SID>/COMM/Bilendo_IN/Inbound directory (set automatically)
P_DELETECheckbox–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 --> DONE

Customization 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/'.   " ← anpassen

System 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 ObjectDescription
F_KNA1_BEDChange customer master
F_KNB1_BEDChange customer master (company code)
F_BKPF_BUKCompany code access FI
S_DATASETFile 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:

The email configuration is set up within the class (→ 03 - Assist Class, method send_email).