Для сторно FI-документа используется функциональный модуль (BAPI) BAPI_ACC_DOCUMENT_REV_POST.
Пример:
Пример:
DATA: ls_bkpf TYPE bkpf, ls_reversal TYPE bapiacrev, lv_obj_type TYPE bapiacrev-obj_type, lv_obj_key TYPE bapiacrev-obj_key, lv_obj_sys TYPE bapiacrev-obj_sys, lt_return TYPE TABLE OF bapiret2. FIELD-SYMBOLS: <lfs_return> LIKE LINE OF lt_return. SELECT SINGLE * FROM bkpf INTO ls_bkpf WHERE bukrs EQ uv_bukrs AND belnr EQ uv_belnr AND gjahr EQ uv_gjahr. CHECK sy-subrc EQ 0. ls_reversal-obj_type = ls_bkpf-awtyp. ls_reversal-obj_key = ls_bkpf-awkey. ls_reversal-obj_key_r = ls_bkpf-belnr && ls_bkpf-bukrs && ls_bkpf-gjahr. ls_reversal-reason_rev = '01'. CALL FUNCTION 'BAPI_ACC_DOCUMENT_REV_POST' EXPORTING reversal = ls_reversal bus_act = 'RFBU' IMPORTING obj_type = lv_obj_type obj_key = lv_obj_key obj_sys = lv_obj_sys TABLES return = lt_return. LOOP AT lt_return ASSIGNING <lfs_return> WHERE type CA 'EAX'. EXIT. ENDLOOP. IF sy-subrc EQ 0. ROLLBACK WORK. ELSE. COMMIT WORK AND WAIT. ENDIF.
Комментариев нет:
Отправить комментарий