备注
此bapi有个bug,更新价格时会把实际价格标志清空掉
在function K_PLAN_ITEM_CHECK_RKP2 判断cssl有没有数据
第一次创建,没有的话会设置默认值
更新时判断有值,会多次move覆盖掉
在后面的form check_tarkz中做个隐式增强,把值还原回去
demo
form frm_save_data changing cs_output like ty_output.
data: ls_headerinfo type bapiplnhdr,
lt_indexstructure type standard table of bapiacpstru,
ls_indexstructure type bapiacpstru,
lt_coobject type standard table of bapiacpobj,
ls_coobject type bapiacpobj,
lt_pervalue type standard table of bapiacpval,
ls_pervalue type bapiacpval,
lt_return type standard table of bapiret2,
ls_return type bapiret2.
ls_headerinfo-co_area = cs_output-kokrs.
ls_headerinfo-fisc_year = cs_output-gjahr.
ls_headerinfo-period_from = cs_output-monat.
ls_headerinfo-period_to = cs_output-monat.
ls_headerinfo-version = cs_output-versn."'2'.选择版本号 modify by shenyan 20211122
ls_headerinfo-plan_currtype = 'C'.
ls_indexstructure-object_index = 0001.
ls_indexstructure-value_index = 0001.
append ls_indexstructure to lt_indexstructure.
ls_coobject-object_index = 0001.
ls_coobject-costcenter = cs_output-kostl.
ls_coobject-acttype = cs_output-lstar.
append ls_coobject to lt_coobject.
ls_pervalue-value_index = 0001.
assign component 'PRICE_FIX_PER' && cs_output-monat of structure ls_pervalue to field-symbol(
if sy-subrc eq 0.
endif.
assign component 'PRICE_UNIT_PER' && cs_output-monat of structure ls_pervalue to field-symbol(
if sy-subrc eq 0.
endif.
ls_pervalue-currency = gs_output-waers.
append ls_pervalue to lt_pervalue.
set update task local.
call function 'BAPI_COSTACTPLN_POSTACTOUTPUT'
exporting
headerinfo = ls_headerinfo
tables
indexstructure = lt_indexstructure
coobject = lt_coobject
pervalue = lt_pervalue
return = lt_return.
loop at lt_return into ls_return where type = 'E' or type = 'A'.
exit.
endloop.
if sy-subrc = 0.
call function 'BAPI_TRANSACTION_ROLLBACK'.
cs_output-msgty = icon_red_light.
cs_output-msgtx = ls_return-message.
else.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.
cs_output-msgty = icon_green_light.
cs_output-msgtx = '处理成功'(019).
endif.
endform.