[ABAP] BAPI zum Lesen der Daten eines Debitoren / Customers

* Typen
TYPES: ty_it_bapicustomer_02 TYPE STANDARD TABLE OF bapicustomer_02 WITH DEFAULT KEY.
TYPES: ty_it_bapicustomer_03 TYPE STANDARD TABLE OF bapicustomer_03 WITH DEFAULT KEY.
TYPES: ty_it_bapicustomer_06 TYPE STANDARD TABLE OF bapicustomer_06 WITH DEFAULT KEY.

* Führende Nullen beim Debitor/Customer beachten!
DATA(lv_deb) = CONV bapicustomer_id-customer( |{ |10000| WIDTH = 10 ALPHA = IN }| ).

* Rückgabestrukturen
DATA(lv_adr) = VALUE bapicustomer_04( ).
DATA(lv_kna1) = VALUE bapicustomer_kna1( ).
DATA(lv_comp) = VALUE bapicustomer_05( ).
DATA(lv_ret) = VALUE bapiret1( ).

* Rückgabetabellen
DATA(it_bank) = VALUE ty_it_bapicustomer_02( ).
DATA(it_iban) = VALUE ty_it_bapicustomer_03( ).
DATA(it_sepa) = VALUE ty_it_bapicustomer_06( ).

* Detailangaben Debitor (KUNNR (KNA1))
CALL FUNCTION 'BAPI_CUSTOMER_GETDETAIL2'
  EXPORTING
    customerno            = lv_deb
*   COMPANYCODE           =
  IMPORTING
    customeraddress       = lv_adr
    customergeneraldetail = lv_kna1
    customercompanydetail = lv_comp
    return                = lv_ret
  TABLES
    customerbankdetail    = it_bank
    customeribandetail    = it_iban
    customersepadetail    = it_sepa.

* Meldungstyp: S Success, E Error, W Warning, I Info, A Abort
CASE lv_ret-type.
  WHEN 'E' OR 'A'.
* Fehler
    cl_demo_output=>write_data( lv_ret ).
    cl_demo_output=>display( ).
  WHEN OTHERS.
* keine Fehler
    cl_demo_output=>write_data( lv_adr ).
    cl_demo_output=>write_data( lv_kna1 ).
    cl_demo_output=>write_data( lv_comp ).
    cl_demo_output=>write_data( it_bank ).
    cl_demo_output=>write_data( it_iban ).
    cl_demo_output=>write_data( it_sepa ).
    cl_demo_output=>write_data( lv_ret ).
    cl_demo_output=>display( ).
ENDCASE.