cancel
Showing results for 
Search instead for 
Did you mean: 

How to update the condition type

Former Member
0 Kudos

Hi,

I have an issue. How to update the condition type of for an item in Sales Order using the BAPI 'BAPI_SALESORDER_CHANGE'.

I have passed the following fields for the updation of the condition type value for an item.

ITM_NUMBER

COND_TYPE

COND_VALUE

CURRENCY of BAPICOND

ITM_NUMBER

COND_TYPE

UPDATEFLAG

COND_VALUE

CURRENCY of BAPICONDX

But, I am not able to get the result.

Can anybody clarify regarding this issue?

Thanks in advance.

Suvan

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Suvan

I suppose that your data is all right and you try to change only manual conditions, so I know to save the order created by BAPI_SALESORDER_CREATEFROMDATA2 it needs to call the BAPI for the commit (I don't remember the name but you can search with BAPICOMMIT), I think that BAPI probably have to be called here, have you called it?

Max

Former Member
0 Kudos

HI,

Here is the code I used. And Please note that I called the function module 'BAPI_TRANSACTION_COMMIT'.

<b>

REPORT YTEST_SO_CHANGE2.

parameters:

p_vbeln like BAPIVBELN-VBELN.

DATA: HEADER LIKE BAPISDH1.

DATA : HEADERX LIKE BAPISDH1X.

DATA: I_PARTNERS LIKE BAPIPARNR OCCURS 0 WITH HEADER LINE.

DATA: I_ITEM LIKE BAPISDITM OCCURS 0 WITH HEADER LINE.

DATA: I_ITEMX LIKE BAPISDITMX OCCURS 0 WITH HEADER LINE.

DATA: RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.

DATA: ORD_TEXT LIKE BAPISDTEXT OCCURS 0 WITH HEADER LINE.

DATA: I_SHLINE LIKE BAPISCHDL OCCURS 0 WITH HEADER LINE.

DATA: I_SHLINEX LIKE BAPISCHDLX OCCURS 0 WITH HEADER LINE.

DATA : ORDER LIKE VBAK-VBELN.

DATA: T_CONDITION LIKE STANDARD TABLE OF BAPICOND WITH HEADER LINE.

DATA: T_CONDITIONX LIKE STANDARD TABLE

OF BAPICONDX

WITH HEADER LINE.

HEADERX-UPDATEFLAG = 'U'.

CLEAR T_CONDITION.

MOVE:

'000010' TO T_CONDITION-ITM_NUMBER,

'ZPR0' TO T_CONDITION-COND_TYPE,

'1' TO T_CONDITION-COND_VALUE,

'USD' TO T_CONDITION-CURRENCY.

APPEND T_CONDITION.

CLEAR T_CONDITIONX.

MOVE:

'000010' TO T_CONDITIONX-ITM_NUMBER,

'ZPR0' TO T_CONDITIONX-COND_TYPE,

'X' TO T_CONDITIONX-COND_VALUE,

'X' TO T_CONDITIONX-CURRENCY,

'U' TO T_CONDITIONX-UPDATEFLAG.

APPEND T_CONDITIONX.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

salesdocument = p_vbeln

ORDER_HEADER_IN = header

order_header_inx = headerx

tables

return = return

CONDITIONS_IN = t_condition

CONDITIONS_INX = t_conditionx.

LOOP AT RETURN.

WRITE : / RETURN-TYPE, RETURN-MESSAGE.

ENDLOOP.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .</b>

Please look at the code.

Thanks,

Suvan.

Former Member
0 Kudos

As far as I know the ConditionX table should only contain X's for all fields that need to be updated (apart from the updateflag ofcourse). This should do the trick.

CLEAR T_CONDITION.

MOVE:

'000010' TO T_CONDITION-ITM_NUMBER,

'ZPR0' TO T_CONDITION-COND_TYPE,

'1' TO T_CONDITION-COND_VALUE,

'USD' TO T_CONDITION-CURRENCY.

APPEND T_CONDITION.

CLEAR T_CONDITIONX.

MOVE:

'X' TO T_CONDITIONX-ITM_NUMBER,

'X' TO T_CONDITIONX-COND_TYPE,

'X' TO T_CONDITIONX-COND_VALUE,

'X' TO T_CONDITIONX-CURRENCY,

'U' TO T_CONDITIONX-UPDATEFLAG.

APPEND T_CONDITIONX.

Former Member
0 Kudos

Hi friends, Thanks for co-operation.

I have got the solution for it. In the sales document change BAPIs, no provision is made to change a pricing condition. You can add a new entry (and thus deactivate prior versions of the condition), but not change an existing condition. This is a problem when you have a condition type that may have more than one effective version in an order.

For example, customer expected price (EDI1) may be maintained by BAPI. But, if an entry already exists, the BAPI will add an additional EDI1 condition, instead of modifying the existing one. Because the expected price functionality is triggered by comparison with the first EDI1 only, miscalculations result when the customer's expected price is modified.

SAP has documented that there is no support for condition changes via BAPI.

So, the remedy for this is that we need to use the bapi twice, first to reset all the condition types and then again insert new values.

This is a two step process because the BAPI to change sales orders, BAPI_SALESORDER_CHANGE, doesn't have the functionality to update conditions. So, what we have to do is call the change BAPI first with the bare minimum fields populated and the logic switch set to 'B' carry out new pricing). This will reset the conditions we needed to reset, ZR00 and ZN02 prices. Of course, after this call we need to commit the changes to the database. Secondly, we make another call to the change BAPI, this time we include the new ZR00 and ZN02 prices. And then commit the changes to the DB. This ain't the prettiest thing in the world, but it works.

Ofcourse, I have also got this from another discussion group. And that it would be helpful to persons in this discussion group also.

So, posting the answer.

Thanks & Regards,

Suvan.

Former Member
0 Kudos

Thanks Sankar for sharing this with the forum. This kind of knowledge sharing is what keeps the forum alive.

Please close the post as solved by you.

Thanks again,

Srinivas

Former Member
0 Kudos

Hi,

Can you post the exact code?