![DEMO:修改销售订单BAPI_SALESORDER_CHANGE DEMO:修改销售订单BAPI_SALESORDER_CHANGE](https://i-blog.csdnimg.cn/blog_migrate/fe5f561a9bb75e5427583d194c04e41c.jpeg)
report zdemo_va02.
parameters p_vbeln type vbeln_va.
parameters p_kschl type konv-kschl.
parameters p_value type konv-kawrt.
parameters p_ass type ordnr_v.
data:ls_vbak type vbak.
data:ls_konv type konv.
data:ls_order_header_in like bapisdh1.
data:ls_order_header_inx like bapisdh1x.
data:logic_switch like bapisdls.
data:lt_conditions_in like table of bapicond,
lt_conditions_inx like table of bapicondx.
data:ls_conditions_in like bapicond,
ls_conditions_inx like bapicondx.
data: lt_return like table of bapiret2.
start-of-selection.
select single * from vbak into ls_vbak where vbeln = p_vbeln.
select single * from konv into ls_konv
where knumv = ls_vbak-knumv
and kschl = p_kschl
and ( kinak = '' or kinak = 'A')..
check sy-subrc = 0.
*&clear
clear: ls_order_header_in,ls_order_header_inx, lt_return[],lt_conditions_in[],lt_conditions_inx[].
*& header
clear ls_order_header_in.
clear ls_order_header_inx.
ls_order_header_in-ass_number = p_ass.
ls_order_header_inx-updateflag = 'U'.
ls_order_header_inx-ass_number = 'X'.
clear ls_conditions_in.
ls_conditions_in-itm_number = 10.
ls_conditions_in-cond_st_no = ls_konv-stunr.
ls_conditions_in-cond_count = ls_konv-zaehk.
ls_conditions_in-cond_type = p_kschl. "定价条件
ls_conditions_in-cond_value = p_value.
ls_conditions_in-currency = 'RMB'. "币别 如果是百分百,则置空
append ls_conditions_in to lt_conditions_in.
clear ls_conditions_inx.
ls_conditions_inx-itm_number = 10.
ls_conditions_inx-cond_st_no = ls_konv-stunr.
ls_conditions_inx-cond_count = ls_konv-zaehk.
ls_conditions_inx-updateflag = 'U'.
ls_conditions_inx-cond_type = p_kschl. "定价条件
ls_conditions_inx-cond_value = 'X'. "价格
ls_conditions_inx-currency = 'X'. "
append ls_conditions_inx to lt_conditions_inx.
logic_switch-cond_handl = 'X'.
call function 'BAPI_SALESORDER_CHANGE'
exporting
salesdocument = p_vbeln
order_header_in = ls_order_header_in
order_header_inx = ls_order_header_inx
logic_switch = logic_switch
tables
return = lt_return
conditions_in = lt_conditions_in
conditions_inx = lt_conditions_inx.
call function 'BAPI_TRANSACTION_COMMIT'
exporting
wait = 'X'.