Skip to Content
0
Feb 09, 2012 at 07:26 AM

VA01 Enhancement Not Working Properly

58 Views

Hi,

I am doing one enhancement in VA01 inside include MV45AFZZ inside form USEREXIT_SAVE_DOCUMENT_PREPARE.

I am adding a SO line item wise Quantity check against referenced Quotation's Quantity with +ve Tolerance.

Sum of SO quantities item wise shouldn't exceed referenced Quotation's Qty + Over delivery Tolerance in that.

One Peculiar thing is happening when I am calculating the percentage for the above logic in below code is not giving correct values.

ENHANCEMENT 1  ZSD_SOCON_QTY_CHECK.    "ACTIVE VERSION

IF VBAK-VGBEL IS NOT INITIAL.

  DATA: LWA_XVBFA  LIKE XVBFA,
        LV_ZMENG   TYPE DZMENG,
        LV_UEBTO   TYPE UEBTO,
        LV_TOL_QTY TYPE RFMNG,
        LV_SUM_QTY TYPE RFMNG.

  LOOP AT XVBFA WHERE POSNV IS NOT INITIAL.

    SELECT SINGLE ZMENG UEBTO FROM VBAP
           INTO (LV_ZMENG,LV_UEBTO)
           WHERE VBELN = XVBFA-VBELV
           AND POSNR = XVBFA-POSNV.

    LV_TOL_QTY = LV_ZMENG + ( LV_ZMENG * ( LV_UEBTO / 100 ) ).

    LOOP AT XVBFA INTO LWA_XVBFA
         WHERE POSNV IS NOT INITIAL
         AND POSNN EQ XVBFA-POSNN.
      LV_SUM_QTY = LV_SUM_QTY + LWA_XVBFA-RFMNG.
    ENDLOOP.

    IF LV_SUM_QTY > LV_TOL_QTY.
      MESSAGE 'SO Qty Exceeds Contract Qty + Tolerance' TYPE 'E'.
    ENDIF.
  ENDLOOP.

ENDIF.

ENDENHANCEMENT.

Taking a example:

OutPut

LV_ZMENG 150000.000

LV_UEBTO 10.0

LV_TOL_QTY 300000.000

I checked with a Sample SE38 program.Calculation is happening correctly in that.but i dont know why it is behaving like this.

I have checked all the possibilities to resolve that,data type format of destination variable, watch points whether it is changing for other reason etc.

thanks in advance for early reply.

Edited by: Rob Burbank on Feb 11, 2012 6:35 PM