Skip to Content
author's profile photo Former Member
Former Member

Sales Order Header Pricing duplicating while creating order through user exit

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)
Add comment
10|10000 characters needed characters exceeded

8 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 03, 2016 at 11:00 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 02, 2016 at 07:22 PM

    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)

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 02, 2016 at 06:37 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 02, 2016 at 06:47 PM

    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)
    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 02, 2016 at 06:55 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 02, 2016 at 07:40 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 03, 2016 at 08:49 PM


    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.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 04, 2016 at 11:29 AM

    Hi

    Try to use the exit USEREXIT_SAVE_DOCUMENT_PREPARE (include MV45AFZZ)

    Add comment
    10|10000 characters needed characters exceeded