Skip to Content
0

Sales Order Header Pricing duplicating while creating order through user exit

Nov 02, 2016 at 06:23 PM

96

avatar image
Former Member

Creating Sales Order in pricing header user exit. We are inserting a condition type based on logic. When we view the sales order we see condition type twice.

s9759.png (26.1 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

8 Answers

Best Answer
avatar image
Former Member Nov 03, 2016 at 11:00 AM
0

Hi

You should use the user-exit for the pricing, USEREXIT_PRICING_PREPARE_TKOMK has to be used to fill comunication structure, so it's called before the pricing

Try to check include RV61AFZB, here you can see the main user-exit for the pricing, the data from sales order (VBAK, VBAP) are in comunication structure KOMK and KOMP

The internal table GT_ZSD_ORDDLV_PLCY can be filled in the same way you're doing in USEREXIT_PRICING_PREPARE_TKOMK

USEREXIT_XKOMV_FUELLEN_O_KONP should be used to change the data of manual condition, but you want to add a new one, so it's better to use USEREXIT_XKOMV_BEWERTEN_END

this exit is called at the end of pricing process, here you can check and modify XKOMV

Max

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 02, 2016 at 07:22 PM
1

Hi

The exit USEREXIT_PRICING_PREPARE_TKOMK should be used to fill the communication structure KOMK and not to fill the condition table KOMV

In your case you should use the exit USEREXIT_XKOMV_FUELLEN_O_KONP (include RV61AFZB)

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 02, 2016 at 06:37 PM
0

Hi

It's a custom condition, so it's not easy to help you with those few informations: try to check if that condition is automatically loaded by your pricing procedure

Max

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 02, 2016 at 06:47 PM
0

Condition Type is manual.

And its assigned to Pricing Procedure

When i comment my code and try to create a sales order manually and add condition type manually its works. It does not show duplicates.

My Code in user exit USEREXIT_PRICING_PREPARE_TKOMK is as below:

if not gt_zsd_orddlv_plcy[] is INITIAL.
clear wa_zsd_orddlv_plcy.
loop at gt_ZSD_ORDDLV_PLCY into wa_ZSD_ORDDLV_PLCY.
read table Xkomv into wa_komv with key kschl = wa_ZSD_ORDDLV_PLCY-KSCHL.
if sy-subrc <> 0.
WA_KOMV-KPOSN = '000000'.
WA_KOMV-ZAEHK = '01'.
WA_KOMV-updkz = 'I'.
WA_KOMV-KSCHL = wa_ZSD_ORDDLV_PLCY-KSCHL.
WA_KOMV-KBETR = wa_ZSD_ORDDLV_PLCY-amount.
if wa_ZSD_ORDDLV_PLCY-CURRENCY is INITIAL.
WA_KOMV-WAERS = 'USD'.
else.
WA_KOMV-WAERS = wa_ZSD_ORDDLV_PLCY-CURRENCY.
endif.
APPEND WA_KOMV TO XKOMV.
CLEAR WA_KOMV.
endif.
clear: wa_ZSD_ORDDLV_PLCY, wa_komv.
endloop.

endif.


3j4go.png (19.5 kB)
xj8ue.png (39.0 kB)
Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi

where is your code?

0
avatar image
Former Member Nov 02, 2016 at 06:55 PM
0

My Code in user exit USEREXIT_PRICING_PREPARE_TKOMK is as below:

if not gt_zsd_orddlv_plcy[] is INITIAL.
clear wa_zsd_orddlv_plcy.
loop at gt_ZSD_ORDDLV_PLCY into wa_ZSD_ORDDLV_PLCY.
read table Xkomv into wa_komv with key kschl = wa_ZSD_ORDDLV_PLCY-KSCHL.
if sy-subrc <> 0.
WA_KOMV-KPOSN = '000000'.
WA_KOMV-ZAEHK = '01'.
WA_KOMV-updkz = 'I'.
WA_KOMV-KSCHL = wa_ZSD_ORDDLV_PLCY-KSCHL.
WA_KOMV-KBETR = wa_ZSD_ORDDLV_PLCY-amount.
if wa_ZSD_ORDDLV_PLCY-CURRENCY is INITIAL.
WA_KOMV-WAERS = 'USD'.
else.
WA_KOMV-WAERS = wa_ZSD_ORDDLV_PLCY-CURRENCY.
endif.
APPEND WA_KOMV TO XKOMV.
CLEAR WA_KOMV.
endif.
clear: wa_ZSD_ORDDLV_PLCY, wa_komv.
endloop.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 02, 2016 at 07:40 PM
0

But we don't have any structures like VBAK, T180, or global internal table gt_ZSD_ORDDLV_PLCY. I need to check the conditions and then add the pricing header.

Please let me know which user exit is the best option.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 03, 2016 at 08:49 PM
0


Thanks Max. It worked fine in USEREXIT_PRICING_PREPARE_TKOMK, when i passed correct values. Got the values from config table to fill same.

Now I have one more issue to update these manual price when user click save. I have tried in the same user exit but its not working. Please is there a better way to do that.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Nov 04, 2016 at 11:29 AM
0

Hi

Try to use the exit USEREXIT_SAVE_DOCUMENT_PREPARE (include MV45AFZZ)

Share
10 |10000 characters needed characters left characters exceeded