Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Creating two pricing conditions using BAPI_SALES_ORDER_CHANGE to header conditions tab

jmrtinz15
Discoverer
0 Kudos

I have a requirement to create and pass back values to two pricing conditions (ZFST and ZFCT) to header level sales orders. I tried using BAPI_SALESORDER_CHANGE but it only creates duplicates of one of the conditions. It does not create both. *Note that these pricing conditions do not exist or have been created at time of sales order creation.

Example below, code creates condition ZFCT and adds the value which works, but instead of creating the other condition I get a duplicate.

Code below. Everything is hardcoded since I am trying to play around with different options but I can't figure it out. I call the BAPI_SALESORDER_CHANGE twice (one for each condition). I don't seem to get errors in the RETURN table but for some reason only one condition gets created while the second does not. Any ideas?

DATA: ls_order_header_inx TYPE bapisdh1x,
ls_logic_switch TYPE bapisdls,
lt_conditions_in TYPE STANDARD TABLE OF bapicond,
ls_conditions_in TYPE bapicond,
lt_conditions_inx TYPE STANDARD TABLE OF bapicondx,
ls_conditions_inx TYPE bapicondx,
lt_return TYPE STANDARD TABLE OF bapiret2,
ls_return_commit TYPE bapiret2.

ls_logic_switch-pricing = 'C'. (Tried changing this to "B" and "C" but nothing works)
ls_order_header_inx-updateflag = 'U'.

ls_conditions_in-itm_number = '00000'.
ls_conditions_inx-itm_number = '00000'.
ls_conditions_in-cond_type = 'ZFST'.
ls_conditions_inx-cond_type = 'ZFST'.
ls_conditions_in-cond_value = '8.95'.
ls_conditions_inx-cond_value = 'X'.
ls_conditions_in-currency = 'USD'.
ls_conditions_inx-currency = 'X'.
ls_conditions_inx-updateflag = 'U'.
APPEND ls_conditions_in TO lt_conditions_in.
APPEND ls_conditions_inx TO lt_conditions_inx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = '0000001028'
order_header_inx = ls_order_header_inx
logic_switch = ls_logic_switch
TABLES
return = lt_return
conditions_in = lt_conditions_in
conditions_inx = lt_conditions_inx.

CLEAR: ls_conditions_in,
ls_conditions_inx,
lt_conditions_in,
lt_conditions_inx,
lt_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = ls_return_commit.

ls_conditions_in-itm_number = '00000'.
ls_conditions_inx-itm_number = '00000'.
ls_conditions_in-cond_type = 'ZFCT'.
ls_conditions_inx-cond_type = 'ZFCT'.
ls_conditions_in-cond_value = '12.95'.
ls_conditions_inx-cond_value = 'X'.
ls_conditions_in-currency = 'USD'.
ls_conditions_inx-currency = 'X'.
ls_conditions_inx-updateflag = 'U'.

APPEND ls_conditions_in TO lt_conditions_in.
APPEND ls_conditions_inx TO lt_conditions_inx.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'
EXPORTING
salesdocument = '0000001028'
order_header_inx = ls_order_header_inx
logic_switch = ls_logic_switch
TABLES
return = lt_return
conditions_in = lt_conditions_in
conditions_inx = lt_conditions_inx.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'
IMPORTING
return = ls_return_commit.

0 REPLIES 0