REPORT y_test_lzy .
DATA: salesdocument LIKE bapivbeln-vbeln,
order_header_inx LIKE bapisdh1x,
order_header_in LIKE bapisdh1,
return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE,
conditions_in TYPE STANDARD TABLE OF bapicond WITH HEADER LINE,
conditions_inx TYPE STANDARD TABLE OF bapicondx WITH HEADER LINE,
logic_switch LIKE bapisdls.
DATA:lv_msgtxt TYPE char100.
LOOP AT p
t_ztxnth INTO DATA(ls_ztxnth) WHERE bz = 1.
READ TABLE lt_konv_th INTO DATA(ls_konv_th) WITH KEY vbeln = ls_ztxnth-vbeln_th
posnr = ls_ztxnth-posnr_th.
IF sy-subrc = 0.
salesdocument = ls_ztxnth-vbeln_th.
logic_switch-cond_handl = 'X'.
order_header_inx-updateflag = 'U'.
conditions_in-itm_number = ls_ztxnth-posnr_th.
conditions_in-cond_type = 'YA04'.
"差价 = 原销售订单总价格 - 退回订单总价
conditions_in-cond_value = ls_ztxnth-kbetr - ls_konv_th-kbetr.
conditions_in-currency = 'CNY'.
conditions_in-cond_p_unt = 1.
APPEND conditions_in.
conditions_in-itm_number = ls_ztxnth-posnr_th.
conditions_inx-cond_type = 'YA04'.
conditions_inx-updateflag = 'U'.
conditions_inx-cond_value = 'X'.
conditions_inx-currency = 'X'.
conditions_inx-cond_p_unt = 1.
APPEND conditions_inx.
ENDIF.
- ls_ztxnth-kbetr_th = conditions_in-cond_value + ls_konv_th-kbetr.
ls_ztxnth-bz = 2.
MODIFY pt_ztxnth FROM ls_ztxnth.
ENDLOOP.
DELETE conditions_in WHERE cond_value = 0.
IF conditions_in[] IS NOT INITIAL.
PERFORM sapgui_progress_indicator USING ‘退货销售订单正在调整差价’."进度条显示
CALL FUNCTION ‘BAPI_SALESORDER_CHANGE’
EXPORTING
salesdocument = salesdocument
order_header_in = order_header_in
order_header_inx = order_header_inx
logic_switch = logic_switch
TABLES
return = return
conditions_in = conditions_in
conditions_inx = conditions_inx.
CLEAR lv_msgtxt.
LOOP AT return INTO DATA(la_return)
WHERE type = ‘E’
OR type = ‘A’
OR ( type = ‘W’ AND id = ‘V1’ AND number = ‘555’ ).
IF lv_msgtxt NS la_return-message.
CONCATENATE lv_msgtxt la_return-message INTO lv_msgtxt SEPARATED BY ‘/’ .
ENDIF.
ENDLOOP.
ENDIF.