[ABAP] Fixkontentabelle (T030) auslesen

* Kontenplan
DATA: lv_ktopl TYPE ktopl.
* Vorgangsschlüssel
DATA: lv_ktosl TYPE ktosl.
* Bewertungsmodifikationskonstante
DATA: lv_bwmod TYPE bwmod.
* Konto-Modifikation
DATA: lv_komok TYPE komok.
* Bewertungsklasse
DATA: lv_bklas TYPE bklas.
* Nummer des Sachkontos
DATA: lv_konts TYPE saknr.
* Nummer des Sachkontos
DATA: lv_konth TYPE saknr.

SELECT-OPTIONS: so_ktopl FOR lv_ktopl.
SELECT-OPTIONS: so_ktosl FOR lv_ktosl.
SELECT-OPTIONS: so_bwmod FOR lv_bwmod.
SELECT-OPTIONS: so_komok FOR lv_komok.
SELECT-OPTIONS: so_bklas FOR lv_bklas.
SELECT-OPTIONS: so_konts FOR lv_konts.
SELECT-OPTIONS: so_konth FOR lv_konts.

START-OF-SELECTION.

* T030 (Fixkontentabelle)
  SELECT *
    INTO TABLE @DATA(it_t030)
    FROM t030
    WHERE ktopl IN @so_ktopl.
*      ktosl IN @so_ktosl
*      bwmod IN @so_bwmod
*      komok IN @so_komok
*      bklas IN @so_bklas
*      konts IN @so_konts
*      konth IN @so_konth.

  IF sy-subrc = 0.
    TRY.
        DATA: o_salv TYPE REF TO cl_salv_table.

        cl_salv_table=>factory( EXPORTING
                                  r_container  = cl_gui_container=>default_screen
                                IMPORTING
                                  r_salv_table = o_salv
                                CHANGING
                                  t_table      = it_t030 ).

        o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
        o_salv->get_columns( )->set_optimize( abap_true ).
        o_salv->get_functions( )->set_all( ).
        o_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).
        o_salv->display( ).

        WRITE: / space.
      CATCH cx_root INTO DATA(e_text).
        WRITE: / e_text->get_text( ).
    ENDTRY.
  ENDIF.

[ABAP] Einkaufsbestelltext zum Material auslesen

* https://www.berater-wiki.de/SAPscript-Textbaustein_lesen_mit_Funktionsbaustein_READ_TEXT_und_speichern_mit_SAVE_TEXT
* Texte: Anwendungsobjekt
* siehe SE75
CONSTANTS: co_obj_type TYPE thead-tdobject VALUE 'MATERIAL'. " Materialtexte Einkauf/Lagerung
* Text-ID
* siehe SE75 --> Doppelklick auf Objekt
CONSTANTS: co_obj_id TYPE thead-tdid VALUE 'BEST'. " Einkaufsbestelltext

DATA: it_thead TYPE STANDARD TABLE OF thead WITH DEFAULT KEY.
DATA: it_lines TYPE tline_t.
DATA: it_ascii TYPE tdtab_c132.

* Materialnummer mit führenden Nullen
DATA(lv_matnr) = CONV matnr( '000000001122334455' ).

* erst 'SELECT_TEXT' zur Prüfung aufrufen (ob Text vorhanden)
* 'READ_TEXT' wirft sonst bei Nichtvorhandensein des Textes eine Abbruchmessage
* Texterstellung Text auswählen
CALL FUNCTION 'SELECT_TEXT'
  EXPORTING
    object                  = co_obj_type
    name                    = CONV thead-tdname( lv_matnr )
    id                      = co_obj_id
    language                = sy-langu
  TABLES
    selections              = it_thead   " Textheader der gefundenen Texte
  EXCEPTIONS
    wrong_access_to_archive = 1
    OTHERS                  = 2.

IF sy-subrc = 0.
  IF lines( it_thead ) > 0.
* Texterstellung Text lesen
    CALL FUNCTION 'READ_TEXT'
      EXPORTING
        id                      = co_obj_id
        language                = sy-langu
        name                    = CONV thead-tdname( lv_matnr )
        object                  = co_obj_type
      TABLES
        lines                   = it_lines " Textzeilen des gelesenen Textes
      EXCEPTIONS
        id                      = 1
        language                = 2
        name                    = 3
        not_found               = 4
        object                  = 5
        reference_check         = 6
        wrong_access_to_archive = 7
        OTHERS                  = 8.

    IF sy-subrc = 0.
      IF lines( it_lines ) > 0.
* Textkonvertierung ITF (SAPscript-Format) in ASCII
* Stile und Formatierungen aus SAP-Script-Text entfernen
        CALL FUNCTION 'CONVERT_ITF_TO_ASCII'
          EXPORTING
            formatwidth       = 132
          IMPORTING
            c_datatab         = it_ascii
          TABLES
            itf_lines         = it_lines
          EXCEPTIONS
            invalid_tabletype = 1
            OTHERS            = 2.
        IF sy-subrc = 0.
          cl_demo_output=>write_data( it_thead ).
          cl_demo_output=>write_data( it_lines ).
          cl_demo_output=>write_data( it_ascii ).
          cl_demo_output=>display( ).
        ENDIF.
      ENDIF.
    ENDIF.
  ENDIF.
ENDIF.

[ABAP] Mengen von einer Mengeneinheit in die Menge zu einer anderen Mengeneinheit umwandeln

DATA: lv_matnr TYPE mara-matnr VALUE '1234567890'.
DATA: lv_menge TYPE ekpo-menge VALUE '1'.
DATA: lv_r_menge TYPE ekpo-menge.

* Wandelt Menge von Quellmengeeinheit in Zielmengeneinheit für Material
* Siehe auch Tabelle: T006
CALL FUNCTION 'MD_CONVERT_MATERIAL_UNIT'
  EXPORTING
    i_matnr              = lv_matnr   " MATNR
    i_in_me              = 'KA'       " Ausgangsmengeneinheit
    i_out_me             = 'ST'       " Zielmengeneeinheit
    i_menge              = lv_menge   " Ausgangsmenge
  IMPORTING
    e_menge              = lv_r_menge " Zielmenge
  EXCEPTIONS
    error_in_application = 1
    error                = 2
    OTHERS               = 3.

IF sy-subrc = 0.

ENDIF.

[ABAP] BAPI zum Lesen von Infos zur Bestellanforderung (BANF)

PARAMETERS: p_banfn TYPE eban-banfn.

START-OF-SELECTION.
  DATA: lv_bapimereqheader TYPE bapimereqheader.
  DATA: it_bapiret2 TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY.
  DATA: it_bapimereqitem TYPE STANDARD TABLE OF bapimereqitem WITH DEFAULT KEY.
  DATA: it_bapimereqaccount TYPE STANDARD TABLE OF bapimereqaccount WITH DEFAULT KEY.
  DATA: it_bapimerqaddrdelivery TYPE STANDARD TABLE OF bapimerqaddrdelivery WITH DEFAULT KEY.
  DATA: it_bapimereqitemtext TYPE STANDARD TABLE OF bapimereqitemtext WITH DEFAULT KEY.
  DATA: it_bapimereqheadtext TYPE STANDARD TABLE OF bapimereqheadtext WITH DEFAULT KEY.
  DATA: it_bapiparex TYPE STANDARD TABLE OF bapiparex WITH DEFAULT KEY.
  DATA: it_bapimedcm_allversions TYPE STANDARD TABLE OF bapimedcm_allversions WITH DEFAULT KEY.
  DATA: it_bapimereqcomponent TYPE STANDARD TABLE OF bapimereqcomponent WITH DEFAULT KEY.
  DATA: it_bapimereqserialno TYPE STANDARD TABLE OF bapimereqserialno WITH DEFAULT KEY.
  DATA: it_bapi_srv_outline TYPE STANDARD TABLE OF bapi_srv_outline WITH DEFAULT KEY.
  DATA: it_bapi_srv_service_line TYPE STANDARD TABLE OF bapi_srv_service_line WITH DEFAULT KEY.
  DATA: it_bapi_srv_limit_data TYPE STANDARD TABLE OF bapi_srv_limit_data WITH DEFAULT KEY.
  DATA: it_bapi_srv_contract_limits TYPE STANDARD TABLE OF bapi_srv_contract_limits WITH DEFAULT KEY.
  DATA: it_bapi_srv_acc_data TYPE STANDARD TABLE OF bapi_srv_acc_data WITH DEFAULT KEY.
  DATA: it_bapi_srv_longtexts TYPE STANDARD TABLE OF bapi_srv_longtexts WITH DEFAULT KEY.

  CALL FUNCTION 'BAPI_PR_GETDETAIL'
    EXPORTING
      number                = p_banfn
      account_assignment    = abap_true
      item_text             = abap_true
      header_text           = abap_true
      delivery_address      = abap_true
*     VERSION               = ' '
      sc_components         = abap_true
      serial_numbers        = abap_true
      services              = abap_true
    IMPORTING
      prheader              = lv_bapimereqheader
    TABLES
      return                = it_bapiret2
      pritem                = it_bapimereqitem
      praccount             = it_bapimereqaccount
      praddrdelivery        = it_bapimerqaddrdelivery
      pritemtext            = it_bapimereqitemtext
      prheadertext          = it_bapimereqheadtext
      extensionout          = it_bapiparex
      allversions           = it_bapimedcm_allversions
      prcomponents          = it_bapimereqcomponent
      serialnumbers         = it_bapimereqserialno
      serviceoutline        = it_bapi_srv_outline
      servicelines          = it_bapi_srv_service_line
      servicelimit          = it_bapi_srv_limit_data
      servicecontractlimits = it_bapi_srv_contract_limits
      serviceaccount        = it_bapi_srv_acc_data
      servicelongtexts      = it_bapi_srv_longtexts.

  cl_demo_output=>write_data( lv_bapimereqheader ).
  cl_demo_output=>write_data( it_bapiret2 ).
  cl_demo_output=>write_data( it_bapimereqitem ).
  cl_demo_output=>write_data( it_bapimereqaccount ).
  cl_demo_output=>write_data( it_bapimerqaddrdelivery ).
  cl_demo_output=>write_data( it_bapimereqitemtext ).
  cl_demo_output=>write_data( it_bapimereqheadtext ).
  cl_demo_output=>write_data( it_bapiparex ).
  cl_demo_output=>write_data( it_bapimedcm_allversions ).
  cl_demo_output=>write_data( it_bapimereqcomponent ).
  cl_demo_output=>write_data( it_bapimereqserialno ).
  cl_demo_output=>write_data( it_bapi_srv_outline ).
  cl_demo_output=>write_data( it_bapi_srv_service_line ).
  cl_demo_output=>write_data( it_bapi_srv_limit_data ).
  cl_demo_output=>write_data( it_bapi_srv_contract_limits ).
  cl_demo_output=>write_data( it_bapi_srv_acc_data ).
  cl_demo_output=>write_data( it_bapi_srv_longtexts ).

* HTML-Code vom Demo-Output holen
  DATA(lv_html) = cl_demo_output=>get( ).

* Daten im Inline-Browser im SAP-Fenster anzeigen
  cl_abap_browser=>show_html( EXPORTING
                                title        = 'BANF-Daten'
                                html_string  = lv_html
                                container    = cl_gui_container=>default_screen ).

* cl_gui_container=>default_screen erzwingen
  WRITE: space.

[ABAP] Übersicht zu wichtigen MM-BAPIs

BAPI                            Bezeichnung                                           Link

BAPI_BILLINGDOC_GETLIST         Detailinformationen zur einer Faktura                 https://codezentrale.de/abap-parallelverarbeitung-multitasking/
BAPI_CONTRACT_CREATE            BAPI zum Anlegen eines Einkaufskontraktes
BAPI_CONTRACT_CHANGE            BAPI zum Ändern eines Einkaufskontraktes
BAPI_CUSTOMER_GETDETAIL2        Detailangaben Debitor                                 https://codezentrale.de/abap-bapi-zum-lesen-der-daten-eines-debitoren-customers/
BAPI_ENTRYSHEET_GETDETAIL       Detaildaten des Erfassungsblatts anzeigen             https://codezentrale.de/abap-lerf-detaildaten-des-erfassungsblatts-anzeigen/
BAPI_GOODSMVT_CREATE            Warenbewegungen mit MB_CREATE_GOODS_MOVEMENT buchen   https://codezentrale.de/abap-warenbewegungen-buchen/
BAPI_MATERIAL_GET_ALL           BAPI zum Lesen von Materialdaten                      https://codezentrale.de/abap-mm-materialdaten-lesen/
BAPI_MATERIAL_GET_DETAIL        Detaildaten zu einem Material ermitteln               https://codezentrale.de/abap-daten-zu-einem-material-matnr-ermitteln/
BAPI_MATERIAL_SAVEDATA          Anlegen und Ändern von Materialstammdaten             https://codezentrale.de/abap-mm-bapi_material_savedata-anlegen-und-aendern-von-materialstammdaten/
BAPI_MATERIAL_STOCK_REQ_LIST    Material - Aktuelle Bedarfs-/Bestandsliste            https://codezentrale.de/abap-mm-aktuelle-bedarfs-bestandsliste-reservierte-bestaende-analog-zur-transaktion-mmbe/
BAPI_PO_CHANGE                  Bestellung ändern                                     https://codezentrale.de/abap-bapi-bestellung-aendern/
BAPI_PO_CREATE1                 Bestellung anlegen                                    https://codezentrale.de/abap-bapis-zum-bestellung-anlegen-lesen-aendern/
BAPI_PO_GETDETAIL1              Detailinformationen für eine Bestellung               https://codezentrale.de/abap-bapi-bestellung-anzeigen/
BAPI_PR_CHANGE                  Change Enjoy Purchase Requisition
BAPI_PR_CREATE                  Create Enjoy Purchase Requisistion
BAPI_PR_GETDETAIL               Get details for one MEREQ Object                      https://codezentrale.de/abap-bapi-zum-lesen-von-infos-zur-bestellanforderung-banf/
BAPI_REQUISITION_CHANGE         Bestellanforderung ändern
BAPI_REQUISITION_CREATE         Bestellanforderung anlegen
BAPI_REQUISITION_GETDETAIL      Details zur Bestellanforderung anzeigen
BAPI_SAG_CHANGE                 Ändern eines Lieferplanes
BAPI_SAG_CREATE                 Anlegen eines Lieferplanes
BAPI_SAG_GETDETAIL              Detail aus Lieferplan auslesen
BAPI_SERVICE_CHANGE             BAPI zum Ändern eines Leistungsstammsatzes
BAPI_SERVICE_CREATE             Anlegen eines Leistungstammsatzes
BAPI_SERVICE_GET_DETAIL         Detaildaten zu einem Leistungsstammsatz lesen
BAPI_USER_GET_DETAIL            Detaildaten eines Benutzers lesen                     https://codezentrale.de/abap-detaildaten-eines-benutzers-lesen/

[ABAP] Materialbelegliste (MB51) anzeigen

Variante 1 (CALL TRANSACTION)

PARAMETERS: p_werk TYPE werks DEFAULT '10'.
PARAMETERS: p_matnr TYPE matnr.
PARAMETERS: p_lgort TYPE lgort_d.
PARAMETERS: p_bwart TYPE bwart.
PARAMETERS: p_charg TYPE charg_d.
PARAMETERS: p_lifnr TYPE lifnr.
PARAMETERS: p_kunnr TYPE kunnr.
PARAMETERS: p_kdauf TYPE kdauf.

START-OF-SELECTION.

* Werk
  SET PARAMETER ID 'WRK' FIELD p_werk.
* Material
  SET PARAMETER ID 'MAT' FIELD p_matnr.
* Lagerort
  SET PARAMETER ID 'LAG' FIELD p_lgort.
* Bewegungsart
  SET PARAMETER ID 'BWA' FIELD p_bwart.
* Charge
  SET PARAMETER ID 'CHA' FIELD p_charg.
* Lieferant
  SET PARAMETER ID 'LIF' FIELD p_lifnr.
* Kunde
  SET PARAMETER ID 'KUN' FIELD p_kunnr.
* Kundenuftrag
  SET PARAMETER ID 'AUN' FIELD p_kdauf.

  CALL TRANSACTION 'MB51' AND SKIP FIRST SCREEN.

Variante 2 (SUBMIT)

* Werk
DATA(lv_werk) = VALUE werks( ).
SELECT-OPTIONS: so_werk FOR lv_werk.
* Warenbegleitscheinnummer
DATA(lv_xabln) = VALUE xabln( ).
SELECT-OPTIONS: so_xabln FOR lv_xabln.
* Referenz-Belegnummer
DATA(lv_xblnr) = VALUE xblnr1( ).
SELECT-OPTIONS: so_xblnr FOR lv_xblnr.

INITIALIZATION.
* Vorbelegung für Werk
  so_werk[] = VALUE #( ( sign = 'I' option = 'EQ' low = '10' high = '' ) ).
  
START-OF-SELECTION.

* MB51 ist eine Reporttransaktion, also kann auch der dahinter
* liegende Report RM07DOCS direkt mit Übergabewerten aufgerufen werden
  SUBMIT rm07docs
    WITH werks IN so_werk
    WITH xabln IN so_xabln
    WITH xblnr IN so_xblnr
    WITH rhier_l = abap_true  " Radiobutton "Hierarchische Liste" aktiv setzen
    WITH rflat_l = abap_false " Radiobutton "Flache Liste" deaktivieren
    AND RETURN.

[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.

[ABAP] BAPI für die Prüfung der Existenz eines Business-Partners

DATA(lv_bp) = CONV bu_partner( '10000' ).
DATA(it_bapi_ret) = VALUE bapiret2_t( ).

* Paket BUPA
* SAP-GP, API: Geschäftspartner auf Existenz prüfen
CALL FUNCTION 'BUPA_EXISTENCE_CHECK'
  EXPORTING
    iv_partner = lv_bp
*   IV_PARTNER_GUID       =
  TABLES
    et_return  = it_bapi_ret.

* IS-H: Nachrichten aus BAPIRET2-Tabelle anzeigen
CALL FUNCTION 'ISH_BAPIRET2_DISPLAY'
  EXPORTING
    amodal_window = abap_false " Fenster modal / amodal anzeigen
  TABLES
    ss_bapiret2   = it_bapi_ret.

[ABAP] Warenbewegungen buchen

TYPES: BEGIN OF ty_s_material,
         matnr         TYPE mara-matnr,                            " Materialnummer
         erfmg         TYPE mseg-erfmg,                            " Menge in Erfassungsmengeneinheit (mseg-erfmg) / Menge (mseg-menge)
         entry_uom_iso TYPE bapi2017_gm_item_create-entry_uom_iso, " ISO-Code Maßeinheit
       END OF ty_s_material.

TYPES: ty_it_material TYPE STANDARD TABLE OF ty_s_material WITH KEY matnr.

PARAMETERS: p_test AS CHECKBOX DEFAULT 'X'.

START-OF-SELECTION.

  DATA(it_material) = VALUE ty_it_material( ( matnr = '0815' erfmg = '1' entry_uom_iso = 'PCE' )
                                            ( matnr = '0816' erfmg = '2' entry_uom_iso = 'PCE' )
                                          ).

* Header
  DATA(lv_header) = VALUE bapi2017_gm_head_01( pstng_date    = sy-datum " Buchungsdatum im Beleg
                                               doc_date      = sy-datum " Belegdatum im Beleg
                                               pr_uname      = sy-uname " Benutzername
                                               gr_gi_slip_no = '12345'  " Warenbegleitscheinnummer
                                               header_txt    = 'Text1'  " Belegkopftext
                                               ref_doc_no    = 'Refdoc' " Nummer des externen Materialscheins
                                             ).

* gm_code (siehe auch Tabelle T158G)
* 01  MB01 (Wareneingang zur Bestellung buchen)
* 02  MB31 (Wareneingang zum Fertigungsauftrag)
* 03  MB1A (Warenentnahme)
* 04  MB1B (Umbuchung)
* 05  MB1C (Wareneingang Sonstige)
* 06  MB11 (Warenbewegung)
* 07  MB04 (Nachverrechnung von Beistellmaterial)
  DATA(lv_mvt_code) = VALUE bapi2017_gm_code( gm_code = '03' ). " Zuordnung Code zu Transaktion für BAPI Warenbewegung

* Items für Bewegungsdaten füllen
  DATA(it_items_to_move) = VALUE bapi2017_gm_item_create_t( FOR <m> IN it_material
                                                            (
                                                              material  = CONV #( <m>-matnr ) " 18-stellige Materialnummer
                                                              plant     = '10'                " Werk
                                                              stge_loc  = '01'                " Lagerort
                                                              move_type = '262'               " Bewegungsart (Bestandsführung)
* KZBEW	(Bewegungskennzeichen)
* ' '  Warenbewegung ohne Referenz
*  B  Warenbewegung zur Bestellung
*  F  Warenbewegung zum Auftrag
*  L  Warenbewegung zum Lieferschein
*  K  Warenbewegung zur Kanban-Anforderung (Nur WM intern)
*  O  Nachverrechnung von Beistellmaterial
*  W  Nachverrechnung von Anteils-/Produkt ME Material
                                                              mvt_ind       = ' '                     " Bewegungskennzeichen (Warenbewegung ohne Referenz)
                                                              entry_qnt     = CONV #( <m>-erfmg )     " Menge in Erfassungsmengeneinheit
                                                              entry_uom_iso = <m>-entry_uom_iso       " ISO-Code Maßeinheit
                                                              gl_account    = ''                      " Nummer des Sachkontos
                                                              gr_rcpt       = 'ABC'                   " Warenempfänger
                                                              costcenter    = '100200'                " Kostenstelle
                                                              orderid       = ''                      " Auftragsnummer
                                                              wbs_elem      = ''                      " Projektstrukturplanelement (PSP-Element)
                                                            )
                                                          ).
  DATA(lv_headret) = VALUE bapi2017_gm_head_ret( ).
  DATA(it_return) = VALUE bapiret2_t( ).

  CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
    EXPORTING
      goodsmvt_header  = lv_header
      goodsmvt_code    = lv_mvt_code
      testrun          = p_test
    IMPORTING
      goodsmvt_headret = lv_headret
    TABLES
      goodsmvt_item    = it_items_to_move
      return           = it_return.

* Fehlerauswertung: E - Error, A - Abort
  LOOP AT it_return ASSIGNING FIELD-SYMBOL(<e>).
    WRITE: / |RETURN [{ <e>-type } { <e>-number }]: { <e>-message }|.
  ENDLOOP.

  DATA(lv_return) = VALUE bapiret2( ).

  IF lines( it_return ) > 0.
* Rollback bei Fehler
    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'
      IMPORTING
        return = lv_return.

    WRITE: / |ROLLBACK [{ lv_return-type } { lv_return-number }]: { lv_return-message }|.
  ELSE.
* Daten verbuchen
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
      EXPORTING
        wait   = abap_true
      IMPORTING
        return = lv_return.

    WRITE: / |COMMIT [{ lv_return-type } { lv_return-number }]: { lv_return-message }|.
  ENDIF.

Links