* Bestellung
PARAMETERS: p_po TYPE bapimepoheader-po_number DEFAULT '0001234567'.
* Testmodus
PARAMETERS: p_test TYPE bapiflag-bapiflag DEFAULT abap_true.
* Authority-Check
PARAMETERS: p_noauth TYPE bapiflag-bapiflag DEFAULT abap_true.
* Returnparameter
DATA: it_return TYPE STANDARD TABLE OF bapiret2 WITH DEFAULT KEY.
* Bestellung Kopfdaten
DATA: lv_bapimepoheader TYPE bapimepoheader.
* Bestellung Kopfdaten (Änderungsleiste)
DATA: lv_bapimepoheaderx TYPE bapimepoheaderx.
* Bestellposition
DATA: it_bapimepoitem TYPE STANDARD TABLE OF bapimepoitem WITH DEFAULT KEY.
* Bestellung Positionsdaten (Änderungsleiste)
DATA: it_bapimepoitemx TYPE STANDARD TABLE OF bapimepoitemx WITH DEFAULT KEY.
* Headerdaten
lv_bapimepoheader = VALUE #( po_number = p_po
pmnttrms = 'ZB03'
).
* Flags zum Ändern der Headerdaten
lv_bapimepoheaderx = VALUE #( po_number = abap_true
pmnttrms = abap_true
).
* Positionsdaten
it_bapimepoitem = VALUE #( ( po_item = '00001'
quantity = '1.0'
)
).
* Flags zum Ändern der Positionsdaten
it_bapimepoitemx = VALUE #( ( po_item = '00001'
po_itemx = abap_true
quantity = abap_true
)
).
* Bestellung ändern
CALL FUNCTION 'BAPI_PO_CHANGE'
EXPORTING
purchaseorder = p_po
no_authority = p_noauth
testrun = p_test
poheader = lv_bapimepoheader
poheaderx = lv_bapimepoheaderx
TABLES
return = it_return
poitem = it_bapimepoitem
poitemx = it_bapimepoitemx.
* Wenn keine Fehler, dann COMMIT
IF NOT line_exists( it_return[ type = 'E' ] ).
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = abap_true.
ENDIF.
* Ausgabe der Meldungen
cl_demo_output=>write_data( it_return ).
* HTML-Code holen
DATA(lv_html) = cl_demo_output=>get( ).
* Daten im Inline-Browser im SAP-Fenster anzeigen
cl_abap_browser=>show_html( EXPORTING
title = 'Daten zur Bestellung'
html_string = lv_html
container = cl_gui_container=>default_screen ).
* cl_gui_container=>default_screen erzwingen
WRITE: space.