Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SD user exit

Former Member
0 Kudos

I am having a bit of a momement here.  I know this should be easy but I just can;t see what I am doing wrong.  I want to re-calculate the order quantity when a user enters a new line or changes a line.

I thought I could use MV45AFZB-USEREXIT_CHECK_VBAP, which works initially, and sets my value to what it should be.  But then if i change that line again it always reverts back to the first calcualted value, and the user exit is not being invoked.

So I tried MV45AFZZ-USEREXIT_MOVE_FIELD_TO_VBAP but it only works on new lines.

I tried  MV45AFZZ-USEREXIT_MOVE_FIELD_TO_VBEP and looping round yvbap, but then I get into the same problem as the CHECK_VBAP in that if I try to change the line again it always reverts back to the original calculated value???

  if vbap-kwmeng > 0.

*  +AF231012 add minimum order qty check for customer info rec materials

   select single minlf megru into (lv_minlf, lv_megru)

          from knmt

          where vkorg = vbak-vkorg

          and   vtweg = vbak-vtweg

          and   kunnr = vbak-kunnr

          and   matnr = vbap-matnr.

   if sy-subrc = 0.

     CALL FUNCTION 'CONVERSION_EXIT_CUNIT_INPUT'

       EXPORTING

         input               = lv_megru

        LANGUAGE             = SY-LANGU

      IMPORTING

        OUTPUT               = lv_megru

      EXCEPTIONS

        UNIT_NOT_FOUND       = 1

        OTHERS               = 2.

     IF sy-subrc <> 0.



     ENDIF.



*    now get the Unit of measure mapping

     select single umrez into lv_umrez

            from marm

            where matnr = vbap-matnr

            and   meinh = lv_megru.



     lv_min_qty = lv_umrez * lv_minlf.

*    divide for example our EA's into Cartons and update the qty with the rounded down figure

*    not sure why Tomy system multiplies things up, doesn't happen in other systems

     lv_int = ( yvbap-kwmeng DIV lv_umrez ) DIV 1000.   "DIV calcs the integer quotient - always rounds down

*    now we have for example the number of cartons that can be used so now convert this back to EA's

     vbap-kwmeng = ( lv_int * lv_umrez ) * 1000.

     if vbap-kwmeng LT lv_min_qty.   "if less than min qty change to min qty

       vbap-kwmeng = lv_min_qty.

     endif.



     clear us_dialog.

     MESSAGE S902 WITH vbap-matnr lv_megru.

   endif.

endif.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI, I sorted this in the end.  The issues I had was when updating VBAP the order qty then greyed out, so it could not be changed again.  This was because the VBAP order qty was out of sync with the VBEP order qty.  So in the end I just updated VBEP from the VBEP user exit and the VBAP order qty updates accordingly.  Thanks for the help though.

3 REPLIES 3

Former Member
0 Kudos

Hi,

  User-exit : MV45AFZZ-USEREXIT_MOVE_FIELD_TO_VBAP is the most suitable one for your requirement. Refering to your point, "So I tried MV45AFZZ-USEREXIT_MOVE_FIELD_TO_VBAP but it only works on new lines.", is it not triggering on changing the quantity? or its not overwriting the quantity? whats the exact issue here when you use this exit? It would help me for better understanding.

Also, I suggest you to try using RV45A-KWMENG(holds the latest quantity from item), instead of VBAP-KWMENG for your calculations and finally overwrite the value on VBAP-KWMENG.

Hope this helps..

eduardo_hinojosa
Active Contributor
0 Kudos

Hi Andy,

I think you'll solve it with tools for rounding. Please see the article "Quantity Rounding In Sales Orders" by Amit Kokane in this link: http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/504bcd76-51da-2b10-43ae-fc460c7cf...

You could read you have available the enhancement MDR10001if your requirements aren't covered by the IMG tools.

I hope this helps you

Regards

Eduardo

Former Member
0 Kudos

HI, I sorted this in the end.  The issues I had was when updating VBAP the order qty then greyed out, so it could not be changed again.  This was because the VBAP order qty was out of sync with the VBEP order qty.  So in the end I just updated VBEP from the VBEP user exit and the VBAP order qty updates accordingly.  Thanks for the help though.