02-09-2012 7:26 AM
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
02-09-2012 8:21 AM
Hi
I'm not sure about your question, but I undertand that you have a problem related with some values are displayed differently on dynpros than they are saved in the DB. See Note 886532 - Pricing: Displaying and rounding numbers for further information.
Regards
Eduardo
Edited by: Rob Burbank on Feb 11, 2012 6:36 PM
02-09-2012 8:21 AM
Hi
I'm not sure about your question, but I undertand that you have a problem related with some values are displayed differently on dynpros than they are saved in the DB. See Note 886532 - Pricing: Displaying and rounding numbers for further information.
Regards
Eduardo
Edited by: Rob Burbank on Feb 11, 2012 6:36 PM
02-09-2012 8:52 AM
Hi Hinojosa,
Problem is inside code. when I am debugging the code by processing a SO in VA01 or VA02(while clicking on SAVE button),
it is not giving proper value in LV_TOL_QTY variable so that the check condition below that is failing.
example what i have given is when In Contract, Target quantity is 150,000.000 and Overdeliv. Tolerance In that is 10%,then in this program, LV_TOL_QTY is giving me 300000.000 which i am not able to understand.
02-09-2012 5:27 PM
Hi Manoj,
As Ncvajja pointed out may be you are adding up not required values due to lack of clear statement,
but i would also suggest you modify you code to remove the select query out of the loop, its a bad coding practice to have a select query in your loop. have the query outside loop and get teh values in an internal atble using "FOR ALL ENTRIES IN" XVBFA.
then use a read table statement inside the loop.
02-11-2012 6:02 AM
SELECT SINGLE ZMENG UEBTO FROM VBAP
INTO (LV_ZMENG,LV_UEBTO)
WHERE VBELN = XVBFA-VBELV
AND POSNR = XVBFA-POSNV.
LOOP AT XVBFA WHERE POSNV IS NOT INITIAL.
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.
after writing in this also,it is not doing the correct calculation.clear statement is not required as per logic.even I am giving that,It is not calculating LV_TOL_QTY correctly.
pl. help.I have not came across this type of peculiar thing before in SAP.
02-12-2012 6:07 PM
This is due to "Fixed point arithmetic" setting (which set to false) in the main program SAPMV45A. You should re-write your calculation formula as
lv_tot_qty = lv_zmeng + ( ( lv_zmeng * lv_uebto ) / 1000 ).
Regards, Vinod
02-14-2012 6:44 AM
or you can rewrite like this:
LV_TOL_QTY = LV_ZMENG + ( ( LV_UEBTO / 100 )* LV_ZMENG ).
Thanks,
iostreamax.
02-14-2012 8:44 AM
02-09-2012 4:17 PM
I don't see a clear statement inside your loop processing...Have you removed it for sake of posting or is it non existential.
LOOP AT XVBFA WHERE POSNV IS NOT INITIAL.
CLEAR:LV_ZMENG, LV_UEBTO, LV_TOT_QTY, LV_SUM_QTY.
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.
Edited by: Ncvajja on Feb 9, 2012 5:20 PM