Reversal Document Number digunakan untuk data FI yang terlanjur posting di SAP namun datanya salah. Secara standard SAP, untuk mengcancel data yang salah disebut juga Reversal / Pembalikan nilai, dan bisa menggunakan tcode FB08 dengan menginputkan :
[1] Document Number / No. Dokumen
[2] Company Code / Kode Perusahaan
[3] Fiscal Year / Tahun
[4] Reversal Reason / Alasan Pembatalan
contohnya adalah sebagai berikut:
Secara teknikal Abap, jika kita ingin membuat program reversal document bisa menggunakan sample code berikut ini:
FORM cancel_doc USING u_belnr TYPE bkpf-belnr
u_gjahr TYPE bkpf-gjahr
u_bukrs TYPE bkpf-bukrs
u_key TYPE c.
DATA: ls_bkpf TYPE bkpf,
ls_reversal LIKE bapiacrev,
lt_return TYPE TABLE OF bapiret2 WITH HEADER LINE,
ld_message TYPE c LENGTH 200,
ls_t000 TYPE t000.
SELECT SINGLE * FROM bkpf
INTO ls_bkpf
WHERE belnr = u_belnr AND gjahr = u_gjahr AND bukrs = u_bukrs.
IF sy-subrc = 0.
SELECT SINGLE * FROM t000
INTO ls_t000
WHERE mandt = sy-mandt.
IF sy-subrc = 0.
CONCATENATE ls_bkpf-belnr ls_bkpf-bukrs ls_bkpf-gjahr INTO ls_reversal-obj_key.
ls_reversal-reason_rev = '02'.
ls_reversal-pstng_date = sy-datum.
ls_reversal-obj_sys = ls_t000-logsys.
ls_reversal-obj_type = ' BKPFF'.
ls_reversal-obj_key_r = ls_reversal-obj_key.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_REV_CHECK'
EXPORTING
reversal = ls_reversal
bus_act = 'RFBU'
TABLES
return = lt_return.
IF sy-subrc = 0.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_REV_POST'
EXPORTING
reversal = ls_reversal
bus_act = 'RFBU'
TABLES
return = lt_return.
IF sy-subrc = 0.
ld_message = ''.
LOOP AT lt_return.
CONCATENATE lt_return-message lt_return-message_v1 INTO ld_message.
ENDLOOP.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
MESSAGE ld_message TYPE 'I'.
ELSE.
ld_message = ''.
LOOP AT lt_return.
CONCATENATE lt_return-message lt_return-message_v1 INTO ld_message.
ENDLOOP.
MESSAGE ld_message TYPE 'E'.
ENDIF.
ENDIF.
ELSE.
MESSAGE 'Data tidak ada di T000 (Logical System)' TYPE 'E'.
ENDIF.
ELSE.
MESSAGE 'Data tidak ada di BKPF' TYPE 'E'.
ENDIF.
ENDFORM.
Panggil subrutin tersebut dengan menambah PERFORM seperti contoh dibawah ini:
DATA: LD_belnr TYPE bkpf-belnr,
LD_gjahr TYPE bkpf-gjahr,
LD_bukrs TYPE bkpf-bukrs,
LD_key TYPE c.
LD_belnr = '4600000249'.
LD_gjahr = '2700'.
LD_bukrs = '2020'.
LD_key = '1'.
PERFORM cancel_doc USING LD_belnr LD_gjahr LD_bukrs LD_key.
Berikut merupakan source code lengkap program untuk melakukan pembatalan no. dokumen menggunakan BAPI :
DATA: LD_belnr TYPE bkpf-belnr, LD_gjahr TYPE bkpf-gjahr, LD_bukrs TYPE bkpf-bukrs, LD_key TYPE c. LD_belnr = '4600000249'. LD_gjahr = '2700'. LD_bukrs = '2020'. LD_key = '1'. PERFORM cancel_doc USING LD_belnr LD_gjahr LD_bukrs LD_key. FORM cancel_doc USING u_belnr TYPE bkpf-belnr u_gjahr TYPE bkpf-gjahr u_bukrs TYPE bkpf-bukrs u_key TYPE c. DATA: ls_bkpf TYPE bkpf, ls_reversal LIKE bapiacrev, lt_return TYPE TABLE OF bapiret2 WITH HEADER LINE, ld_message TYPE c LENGTH 200, ls_t000 TYPE t000. SELECT SINGLE * FROM bkpf INTO ls_bkpf WHERE belnr = u_belnr AND gjahr = u_gjahr AND bukrs = u_bukrs. IF sy-subrc = 0. SELECT SINGLE * FROM t000 INTO ls_t000 WHERE mandt = sy-mandt. IF sy-subrc = 0. CONCATENATE ls_bkpf-belnr ls_bkpf-bukrs ls_bkpf-gjahr INTO ls_reversal-obj_key. ls_reversal-reason_rev = '02'. ls_reversal-pstng_date = sy-datum. ls_reversal-obj_sys = ls_t000-logsys. ls_reversal-obj_type = ' BKPFF'. ls_reversal-obj_key_r = ls_reversal-obj_key. CALL FUNCTION 'BAPI_ACC_DOCUMENT_REV_CHECK' EXPORTING reversal = ls_reversal bus_act = 'RFBU' TABLES return = lt_return. IF sy-subrc = 0. CALL FUNCTION 'BAPI_ACC_DOCUMENT_REV_POST' EXPORTING reversal = ls_reversal bus_act = 'RFBU' TABLES return = lt_return. IF sy-subrc = 0. ld_message = ''. LOOP AT lt_return. CONCATENATE lt_return-message lt_return-message_v1 INTO ld_message. ENDLOOP. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'. MESSAGE ld_message TYPE 'I'. ELSE. ld_message = ''. LOOP AT lt_return. CONCATENATE lt_return-message lt_return-message_v1 INTO ld_message. ENDLOOP. MESSAGE ld_message TYPE 'E'. ENDIF. ENDIF. ELSE. MESSAGE 'Data tidak ada di T000 (Logical System)' TYPE 'E'. ENDIF. ELSE. MESSAGE 'Data tidak ada di BKPF' TYPE 'E'. ENDIF. ENDFORM.
bueh keren kawan gw satu ini