Code: Alles auswählen.
"-- Komponenten einem neuen Vorgang zuweisen
LOOP AT lt_component ASSIGNING FIELD-SYMBOL(<fs_component>).
lv_tabix = lv_tabix + 1.
"-- Methode "Neu-zuweisen"
CLEAR ls_method.
ls_method-refnumber = lv_tabix.
ls_method-objecttype = 'COMPONENT'.
ls_method-method = 'REASSIGN'.
ls_method-objectkey(12) = ls_header-order_number.
ls_method-objectkey+12(4) = <fs_component>-res_item.
APPEND ls_method TO lt_method.
"-- Methode speichern
CLEAR ls_method.
ls_method-refnumber = lv_tabix.
ls_method-objecttype = space.
ls_method-method = 'SAVE'.
ls_method-objectkey(12) = ls_header-order_number.
ls_method-objectkey+12(4) = <fs_component>-res_item.
APPEND ls_method TO lt_method.
"-- Neuen Vorgang zuweisen
CLEAR ls_component_up.
<fs_component>-activity = lv_vornr.
ls_component_up-activity = 'X'.
APPEND ls_component_up TO lt_component_up.
"-- Aufruf BAPI
CALL FUNCTION 'BAPI_ALM_ORDER_MAINTAIN'
TABLES
it_methods = lt_method
it_component = lt_component
it_component_up = lt_component_up
return = lt_return.
"-- Auf Error prüfen
READ TABLE lt_return INTO ls_return WITH KEY type = 'E'.
IF sy-subrc NE 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
EXIT.
ENDLOOP.