Skip to Content
0
Former Member
Mar 17, 2006 at 03:04 PM

BAPI_SALESORDER_CHANGE update conditions

4845 Views

Hello,

I have a problem with the update of the pricing conditions of sales orders using the bapi BAPI_SALESORDER_CHANGE. Instead of updating the conditions, it creates new conditions.

In this thread: How to update the condition type I found that I first have to call the BAPI_SALESORDER_CHANGE with the logic_witch set to B, and then call the BAPI_SALESORDER_CHANGE with the 'new' pricing conditions, but it will not work...

thanks in advance

Frank

  • Call bapi to reset pricing conditions

CLEAR BAPIRET.

CLEAR BAPIRET2.

CLEAR BAPISDLS.

CLEAR BAPISDLS[].

CLEAR BAPISDH1X.

CLEAR BAPISDH1X[].

BAPISDLS-PRICING = 'B'.

APPEND BAPISDLS.

BAPISDH1X-UPDATEFLAG = 'U'.

APPEND BAPISDH1X.

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = wa_order_information-VBELN

ORDER_HEADER_INX = BAPISDH1X

LOGIC_SWITCH = BAPISDLS

TABLES

RETURN = BAPIRET2.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = BAPIRET.

  • Update condition values

CLEAR BAPISDH1X.

CLEAR BAPISDH1X[].

CLEAR BAPICOND.

CLEAR BAPICOND[].

CLEAR BAPICONDX.

CLEAR BAPICONDX[].

CLEAR BAPIRET2.

BAPISDH1X-UPDATEFLAG = 'U'.

APPEND BAPISDH1X.

BAPICOND-ITM_NUMBER = 0.

BAPICONDX-ITM_NUMBER = 0.

BAPICOND-COND_TYPE = 'ZCP1'.

BAPICONDX-COND_TYPE = 'ZCP1'.

BAPICOND-COND_VALUE = wa_order_information-DIA_OFF_VAL1.

BAPICONDX-COND_VALUE = 'X'.

BAPICOND-CURRENCY = 'EUR'.

BAPICONDX-CURRENCY = 'X'.

BAPICONDX-UPDATEFLAG = 'U'.

APPEND BAPICOND.

APPEND BAPICONDX.

...

CALL FUNCTION 'BAPI_SALESORDER_CHANGE'

EXPORTING

SALESDOCUMENT = wa_order_information-VBELN

ORDER_HEADER_INX = BAPISDH1X

TABLES

RETURN = BAPIRET2

CONDITIONS_IN = BAPICOND

CONDITIONS_INX = BAPICONDX.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

WAIT = 'X'

IMPORTING

RETURN = BAPIRET.