03-17-2006 3:04 PM
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: 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.
04-07-2006 4:37 PM
Hi guys,
To update an existing pricing condition, you need to set the logic_switch field COND_HANDL = 'X'. This will not create a new entry but update the existing one, trust me, I've tried this and it works.
Ruong
03-17-2006 3:34 PM
good luck...I couldn't make it work...the good part is if your pricing procedure accomodates it correctly the value of the latter condition is going to be used.
03-17-2006 3:51 PM
> ...Instead of updating the conditions, it creates
> new conditions.
I found the following in function module SD_SALES_DOCU_MAINTAIN (which is called by BAPI_SALESORDER_CHANGE):
*----------------------------------------------------------------------*
* 08. header-conditions *
*----------------------------------------------------------------------*
IF return IS INITIAL.
* Split up handling of header conditions into two different cases:
* a) standard R/3 handling via function module
* SD_SALES_CONDITION_MAINTAIN (every line checked and processed
* sperately)
* b) handling of header condition coming form a so called 'trusted
* source' as e.g. MSA or CRM (no checks, just take over result)
* See also comments at section 10, item processing.
*
* Case A) R/3 standard
IF NOT ( pricingtype CA 'BCG' AND call_bapi = charx ).
LOOP AT ix_konvkom WHERE kposn IS INITIAL.
CLEAR ix_konvkomx.
...
CALL FUNCTION 'SD_SALES_CONDITION_MAINTAIN'
EXPORTING
fkonvkom = ix_konvkom
fkonvkomx = ix_konvkomx
IMPORTING
e_xkomv = da_komv
EXCEPTIONS
item_num_missing = 1
step_num_missing = 2
count_missing = 3
error_message = 4
OTHERS = 5.
...
* Case 2) Trusted Source. Check analougs to SD_SALES_ITEM_MAINTAIN
ELSEIF ( call_bapi EQ charx AND
pricingtype NE space <b>AND
( NOT ix_konvkom[] IS INITIAL or
vbak-vbkla(2) = 'CR'</b> ) ).
<b>* Delete already existing header condition lines in sales XKOMV and add
* new/updated ones.</b>
PERFORM xkomv_change_konvkom(sapfv45p) TABLES ix_konvkom
USING '000000'
'000000'.
ENDIF.
ENDIF.
Could your processing possibly be hitting "Case 2) Trusted Source" per the bolded lines of code and comments? There are also comments within this same function module regarding conditions on items that may or may not be relevant to your situation:
* a) in case we get a pricing result form a so called 'trusted
* source' (e.g. CRM, Mobile Sales) move this pricing result from
* external table IX_KONVKOM to the internal representation
* IT_KONV_KOMV.
* This table is used later on as input for the next pricing call
* based on the pricing type passed in by the BAPI and triggered via
* VBAP_BEARBEITEN_ENDE. Using this mechanism will avoid
* a single processing of each condition line as it is normally
* executed by SD_SALES_CONDITION_MAINTAIN for 'standard R/3'
* processes.
Since there are two different cases for handling the update of the pricing conditions, I thought I'd point this out so that you can check if this is why you seem to be getting an unexpected result.
Best of luck!
Regards,
James Gaddis
04-07-2006 4:37 PM
Hi guys,
To update an existing pricing condition, you need to set the logic_switch field COND_HANDL = 'X'. This will not create a new entry but update the existing one, trust me, I've tried this and it works.
Ruong
05-08-2006 1:22 PM
Hello,
The following is working code for updating pricing conditions.
U need to give the step_nr, item_nr, cond_count and cond_type so the correct conditon will be updated. If no condition exists for the given parameters, a new condition will be created.
U can find these parameters for a particular condition type in table KONV.
&----
*& Form saveTransactionJOCR
&----
text
----
--> p1 text
<-- p2 text
----
FORM saveTransactionJOCR .
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,
step_nr like conditions_in-cond_st_no,
item_nr like conditions_in-itm_number,
cond_count like conditions_in-cond_count,
cond_type like conditions_in-cond_type.
salesdocument = wa_order_information-VBELN.
LOGIC_SWITCH-COND_HANDL = 'X'.
order_header_inx-updateflag = 'U'.
conditions
clear conditions_in[].
clear conditions_inx[].
clear: step_nr,
item_nr,
cond_count,
cond_type.
step_nr = '710'.
item_nr = '000000'.
cond_count = '01'.
cond_type = 'ZCP2'.
CONDITIONS_IN-ITM_NUMBER = item_nr.
conditions_in-cond_st_no = step_nr.
CONDITIONS_IN-COND_COUNT = cond_count.
CONDITIONS_IN-COND_TYPE = cond_type.
CONDITIONS_IN-COND_VALUE = 666.
CONDITIONS_IN-CURRENCY = 'EUR'.
append conditions_in.
CONDITIONS_INX-ITM_NUMBER = item_nr.
conditions_inx-cond_st_no = step_nr.
CONDITIONS_INX-COND_COUNT = cond_count.
CONDITIONS_INX-COND_TYPE = cond_type.
CONDITIONS_INX-UPDATEFLAG = 'U'.
CONDITIONS_INX-COND_VALUE = 'X'.
CONDITIONS_INX-CURRENCY = 'X'.
append conditions_inx.
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
.
if return-type ne 'E'.
commit work and wait.
endif.
ENDFORM. " saveTransactionJOCR
I hope this works for u too.
Kind regards,
Joren
PS: Don't forget to reward points if this solution is a solution to your problem.
12-26-2006 10:05 AM
Hello,
i am reading your post and i have a question :
the structure "logic_switch" DO NOT HAVE component "COND_HANDL".
This is the structure by SE11 (BAPISDLS) :
<b>PRICING KNPRS</b> CHAR 1
<b>ATP_WRKMOD</b> ATP_WRKMOD CHAR 1
<b>SCHEDULING</b> CHAR1 CHAR 1
<b>NOSTRUCTURE</b> XFELD CHAR 1
> Hello,
>
> The following is working code for updating pricing
> conditions.
>
> U need to give the step_nr, item_nr, cond_count and
> cond_type so the correct conditon will be updated. If
> no condition exists for the given parameters, a new
> condition will be created.
> U can find these parameters for a particular
> condition type in table KONV.
>
>
> FORM saveTransactionJOCR .
> 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,
> step_nr like conditions_in-cond_st_no,
> item_nr like conditions_in-itm_number,
> cond_count like conditions_in-cond_count,
> cond_type like conditions_in-cond_type.
>
> salesdocument = wa_order_information-VBELN.
>
> LOGIC_SWITCH-COND_HANDL = 'X'.
> ...etc...
12-26-2006 10:12 AM
HI Chaouki
Am not sure of your version, but in my version it has 5 parameters, below are the same for your reference:
PRICING KNPRS CHAR 1 0 Pricing type
ATP_WRKMOD ATP_WRKMOD CHAR 1 0 ATP session: Pick up result / new determination APO-ATP
SCHEDULING CHAR1 CHAR 1 0 Single-character flag
NOSTRUCTURE XFELD CHAR 1 0 Checkbox
COND_HANDL NEW_COND_MNT CHAR 1 0 Selection: Condition lines handling (SD document change)
Regards
Eswar
12-26-2006 10:26 AM
Thank you for this information.
"My Component version" is R/3 release <b>4.6C</b>.
04-29-2022 5:57 PM