使用VF11冲销时,将对应销售订单的出具发票计划行打上冻结标记
使用FM:BILLING_SCHEDULE_SAVE实现
if sy-tcode eq 'VF11'.
* break hand-ccc.
data: lt_vbrp type table of vbrp,
ls_vbrp type vbrp.
data: lt_fpla_new type table of fplavb,
ls_fpla_new type fplavb.
data: lt_fpla_old type table of fplavb,
ls_fpla_old type fplavb.
data: lt_fplt_new type table of fpltvb,
ls_fplt_new type fpltvb.
data: lt_fplt_old type table of fpltvb,
ls_fplt_old type fpltvb.
lt_vbrp[] = xvbrp[].
clear ls_vbrp.
loop at lt_vbrp into ls_vbrp.
clear: lt_fpla_old,lt_fplt_old.
clear: lt_fpla_new,lt_fplt_new.
"调用FM读取发票对应的数据
call function 'BILLING_SCHEDULE_READ'
exporting
fplnr = ls_vbrp-fplnr
* I_VFKDAT =
* I_BFKDAT =
tables
zfpla = lt_fpla_old
zfplt = lt_fplt_old.
lt_fpla_new[] = lt_fpla_old[].
lt_fplt_new[] = lt_fplt_old[].
"更新内表,冻结状态设置为02,设置更新标识
clear ls_fplt_new.
ls_fplt_new-faksp = '02'.
ls_fplt_new-updkz = 'U'. "U:UPDATE 必须,不然不会更新
modify lt_fplt_new from ls_fplt_new transporting faksp updkz where fplnr eq ls_vbrp-fplnr and fpltr eq ls_vbrp-fpltr.
"调用FM去更新
call function 'BILLING_SCHEDULE_SAVE'
tables
fpla_new = lt_fpla_new
fpla_old = lt_fpla_old
fplt_new = lt_fplt_new
fplt_old = lt_fplt_old.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
clear ls_vbrp.
endloop.
endif.