04-24-2007 10:46 AM
Hi,
Following code is not giving correct result in user exit:
CONSTANTS:
LC_DCM TYPE RV45A-BTGEW VALUE '5000.000',
LC_FACTOR TYPE RV45A-BTGEW VALUE '0.970'.
DATA: LV_DCM_CAPCTY TYPE RV45A-BTGEW.
CLEAR LV_DCM_CAPCTY.
LV_DCM_CAPCTY = LC_DCM * LC_FACTOR.
Result is coming as '4850000.000' in place of 4850.000.
(Whereas the same code when placed in another custom test program ,is giving correct result as 4850.000).
Can any one help me,where might be the mistake in my user exit?
Code in my user exit is as follows:
*********************************************************************************
********************************************************************************
Constants for difrent load carriers
CONSTANTS:
LC_DCM TYPE RV45A-BTGEW VALUE '5000.000',
LC_DCM TYPE RV45A-BTGEW VALUE '10.000',
LC_TRUCK TYPE RV45A-BTGEW VALUE '8000.000',
LC_TRAILER TYPE RV45A-BTGEW VALUE '10000.000',
LC_FACTOR TYPE RV45A-BTGEW VALUE '0.970'.
****DATA: LV_DCM_CAPCTY TYPE RV45A-BTGEW,
DATA: LV_DCM_CAPCTY TYPE P DECIMALS 3.
CLEAR:LV_DCM_CAPCTY.
LV_DCM_CAPCTY = LC_DCM * LC_FACTOR.
Field symbols
FIELD-SYMBOLS: <FS1>, "Sales org.
<FS2>, "Total weight
<FS3>, "Weight unit
<FS4>. "Volume unit
variables to hold values from Sales order screen
DATA: LV_VKORG TYPE VBAK-VKORG,
LV_TOT_WEIGHT TYPE RV45A-BTGEW,
LV_WT_UNIT TYPE RV45A-GEWEI,
LV_VOL_UNIT TYPE RV45A-VOLEH.
Variables to hold field labels of Sales Ord. screen
DATA:
LABEL_VKORG(20) VALUE '(SAPMV45A)VBAK-VKORG',
LABEL_TOT_WEIGHT(21) VALUE '(SAPMV45A)RV45A-BTGEW',
LABEL_WT_UNIT(21) VALUE '(SAPMV45A)RV45A-GEWEI',
LABEL_VOL_UNIT(21) VALUE '(SAPMV45A)RV45A-VOLEH'.
CLEAR : "<FS1>, "Sales org.
"<FS2>, "Total weight
"<FS3>, "Weight unit
"<FS4>, "Volume unit
LV_VKORG,
LV_TOT_WEIGHT,
LV_WT_UNIT,
LV_VOL_UNIT.
ASSIGN: (LABEL_VKORG) TO <FS1>,
(LABEL_TOT_WEIGHT) TO <FS2>,
(LABEL_WT_UNIT) TO <FS3>,
(LABEL_VOL_UNIT) TO <FS4>.
LV_VKORG = <FS1>.
LV_TOT_WEIGHT = <FS2>.
LV_WT_UNIT = <FS3>.
LV_VOL_UNIT = <FS4>.
LV_DCM_CAPCTY = LC_DCM * LC_FACTOR.
Checks for total weight against carrier capacity
CASE LV_VKORG.
*--->When DCM
WHEN '1101'.
IF LV_TOT_WEIGHT LT LV_DCM_CAPCTY .
MESSAGE E899 WITH 'Document not saved,since'
' full load is not reached'.
ENDIF.
WHEN OTHERS.
ENDCASE.
********************************************************************
********************************************************************
Thanks & Regards,
Seshagiri.
04-24-2007 10:55 AM
it depends upon no.of decimal points of that field.
in this case u have to do like this
a = ( b * c ) / 1000.
<b>but make use this logic works in all situations</b>
Message was edited by:
Prabhu Peram
04-24-2007 10:50 AM
Hi,
The reason for this might be that in one program the Fixed Point arithmetic Checkbox in the attributes section is checked and in the other it is unchecked.
Hence the issue.
Regards,
Himanshu
04-24-2007 11:11 AM
04-24-2007 10:55 AM
it depends upon no.of decimal points of that field.
in this case u have to do like this
a = ( b * c ) / 1000.
<b>but make use this logic works in all situations</b>
Message was edited by:
Prabhu Peram
04-24-2007 11:12 AM
Hi,
Thank you very much.
Got the correct result,with your solution.
Regards,
Seshagiri.