report zdemo_vl09.
parameters p_vbeln type vbeln_vl.
data:lt_likp type table of likp.
data:ls_likp like line of lt_likp.
data:lt_mesg like table of mesg.
data:ls_mesg like line of lt_mesg.
data:ls_emkpf type emkpf.
select single * from likp into ls_likp where vbeln = p_vbeln.
call function 'WS_REVERSE_GOODS_ISSUE'
exporting
i_vbeln = ls_likp-vbeln
i_budat = sy-datum
i_tcode = 'VL09'
i_vbtyp = ls_likp-vbtyp "SD 凭证类别
importing
es_emkpf = ls_emkpf
tables
t_mesg = lt_mesg
exceptions
error_reverse_goods_issue = 1
others = 2.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
write ls_emkpf-mblnr.