通过BAPi BAPI_DOCUMENT_DELETE_DIRECT 可以删除文档。
代码很简单如下:
注意:要用 CONVERSION_EXIT_ALPHA_INPUT转换一下文档号码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
REPORT ztest_delete_dir.
DATA:lwa_return TYPE bapiret2,
l_documentnumber TYPE bapi_doc_aux-docnumber.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = '10000000000000067'
IMPORTING
output = l_documentnumber.
CALL FUNCTION 'BAPI_DOCUMENT_DELETE_DIRECT'
EXPORTING
documenttype = 'TA1'
documentnumber = l_documentnumber
documentpart = '000'
documentversion = '00'
IMPORTING
return = lwa_return.
WRITE:lwa_return-message.
IF lwa_return-type = 'S' OR
lwa_return-type IS INITIAL.
WRITE:'Successful'.
ELSE.
WRITE:'Fail'.
ENDIF.
|
运行后,文档10000000000000067被删除,在tcode cv03n中看不到了
以上。