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: 

Changing Price Conditions in Sales Order with SD_SALESDOCUMENT_CHANGE

e_maino
Explorer
0 Kudos
2,419

Hello there!

I need to change the value of a price condition in a sale order ;I'm using the f.m. SD_SALESDOCUMENT_CHANGE.

It doesnt' work as I want, 'cause it creates an other price conditions instead of just changing the price value of the actual one.

Waiting for your tips,

thanks.

This is how my code looks like:

-


PARAMETER: p_vbeln LIKE vbak-vbeln.

data: st_order_header_inx TYPE bapisdhd1x,

st_conditions LIKE bapicond,

st_conditionsx LIKE bapicondx,

tb_conditions TYPE TABLE OF bapicond,

tb_conditionsx TYPE TABLE OF bapicondx,

tb_return TYPE TABLE OF bapiret2.

st_order_header_inx-updateflag = 'U'.

st_conditions-itm_number = '0010'.

st_conditions-cond_type = 'PR00'.

st_conditions-cond_updat = 'X'.

st_conditions-cond_value = '100'. "Value I want to enter

APPEND st_conditions TO tb_conditions.

st_conditionsx-itm_number = '0010'.

st_conditionsx-cond_type = 'PR00'.

st_conditionsx-updateflag = 'U'.

st_conditionsx-cond_value = 'X'.

APPEND ls_conditionsx TO tb_conditionsx.

CALL FUNCTION 'SD_SALESDOCUMENT_CHANGE'

EXPORTING

salesdocument = p_vbeln

order_header_inx = st_order_header_inx

TABLES

return = tb_return

conditions_in = tb_conditions

conditions_inx = tb_conditionsx .

-


7 REPLIES 7

Former Member
0 Kudos
764

Hi,

Make sure all these things.

1. Minimum entry:

You must enter the order number in the SALESDOCUMENT structure.

You must always enter key fields for changes.

You must always specify the update indicator in the ORDER_HEADER_INX.

2. Commit control:

The BAPI does not run a database Commit, which means that the application must trigger the Commit so that the changes are read to the database. To do this, use the BAPI_TRANSACTION_COMMIT BAPI.

0 Kudos
764

>

> 1. Minimum entry:

> You must enter the order number in the SALESDOCUMENT structure.

> You must always enter key fields for changes.

> You must always specify the update indicator in the ORDER_HEADER_INX.

It's all filled as you can see in the example code...

>

> 2. Commit control:

> The BAPI does not run a database Commit, which means that the application must trigger the Commit so that the changes are read to the database. To do this, use the BAPI_TRANSACTION_COMMIT BAPI.

I forgot it in the example, but i got it in my code...

It sill doesn't work as I want...

Former Member
0 Kudos
764

Hi,

Try like below


st_order_header_inx-updateflag = 'X'.

st_conditions-itm_number = '0010'.
st_conditions-cond_type = 'PR00'.
st_conditions-cond_updat = 'U'.
st_conditions-cond_value = '100'. "Value I want to enter
APPEND st_conditions TO tb_conditions.

st_conditionsx-itm_number = 'X'.
st_conditionsx-cond_type = 'X'.
st_conditionsx-updateflag = 'X'.
st_conditionsx-cond_value = 'X'.
APPEND ls_conditionsx TO tb_conditionsx.

Regards,

Himanshu

0 Kudos
764

>

> st_conditionsx-itm_number = 'X'.

> st_conditionsx-cond_type = 'X'.

> st_conditionsx-updateflag = 'X'.

> st_conditionsx-cond_value = 'X'.

> APPEND ls_conditionsx TO tb_conditionsx.

This doesn't work..

Former Member
0 Kudos
764

Get the conditions records first from the Sales Order with BAPI BAPISDORDER_GETDETAILEDLIST

CALL FUNCTION 'BAPISDORDER_GETDETAILEDLIST'
  EXPORTING
    i_bapi_view          = lw_bapi_view
  TABLES
    sales_documents      = lt_order
    order_conditions_out = lt_conditions_out.

Then populate the conditions internal table with the data that you get from the previous code


move-corresponding lw_conditions_out to lw_order_conditions_in.
lw_order_conditions_in-cond_value = '100'   " the value that you want to modify
APPEND lw_order_conditions_in TO lt_order_conditions_in.

CLEAR lw_order_conditions_inx.
lw_order_conditions_inx-itm_number = lv_kposn.
lw_order_conditions_inx-cond_st_no = lw_conditions_out-cond_st_no.
lw_order_conditions_inx-cond_count = lw_conditions_out-cond_count.
lw_order_conditions_inx-cond_type  = lw_conditions_out-cond_type.
lw_order_conditions_inx-updateflag = 'U'.
lw_order_conditions_inx-cond_value = lc_x.
APPEND lw_order_conditions_inx TO lt_order_conditions_inx.

You didn't populate the fields cond_st_no and -cond_count. Then just call BAPI SD_SALESDOCUMENT_CHANGE to change the Sales order.

Hope that helps.

Erwin

Former Member
0 Kudos
764

I am trying to do the same thing. I tried following Erwin's advise and called BAPISDORDER_GETDETAILEDLIST to populate the conditions first but it still wasn't updating the price. The FM was finishing saying it was updated, but when I looked at the contract, it wasn't. I added a commit work after the SD_SALESDOCUMENT_CHANGE and then the price got updated. Hopefully this helps.

Dan

Frank711
Explorer
0 Kudos
764

Hello,

the Bapi does not really support the change of condtions. Just have a look to the notes 188972 and 357433.

Frank