1 DATA:gv_number TYPE bapi_incinv_fld-inv_doc_no,
2 gv_year TYPE bapi_incinv_fld-fisc_year,
3 gv_number1 TYPE bapi_incinv_fld-inv_doc_no,
4 gv_year1 TYPE bapi_incinv_fld-fisc_year,
5 gt_return TYPE TABLE OF bapiret2,
6 gs_return TYPE bapiret2,
7 zmsg type char255 .
8
9 CALL FUNCTION 'BAPI_INCOMINGINVOICE_CANCEL'
10 EXPORTING
11 invoicedocnumber = gv_number "凭证号
12 fiscalyear = gv_year "年度
13 reasonreversal = '03'
14 postingdate = sy-datum
15 IMPORTING
16 invoicedocnumber_reversal = gv_number1
17 fiscalyear_reversal = gv_year1
18 TABLES
19 return = gt_return.
20
21 IF gv_number1 IS NOT INITIAL .
22
23 CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
24 EXPORTING
25 wait = 'X'.
26
27 ELSE .
28
29 CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
30 LOOP AT gt_return INTO gs_return WHERE type = 'E' .
31 IF zmsg IS INITIAL .
32 zmsg = gs_return-message .
33 ELSE .
34 zmsg = gs_return-message && '/' && zmsg .
35 ENDIF .
36 ENDLOOP .
37
38 ENDIF .