‎2009 Feb 06 11:27 AM
Hi experts,
i am having a problem in coding i wont to convert the MSEG-ERFME field that is quantity field into tonne when ever it is kg. In tcode j1i5 i got one user exit J_1i7_userexit_validate now inside this user exit i have to write this code that when ever the UOM(unit of measure)ERFME comes in KG it should be converted into TONNE, This code is to be written in the user exit and has to be followed forward in other values.
Thanks
sumeet Malhotra
‎2009 Feb 06 11:32 AM
Hi,
You need to convert the unit into the internal format to check for the UOM..
use the below FM :
CONVERSION_EXIT_CUNIT_INPUT Conversion exit for commercial (3-char) measurement unit INPUT
CONVERSION_EXIT_CUNIT_OUTPUT Conversion exit for commercial (3-char) measurement unit OUTPUT
Regardss
Shiva
‎2009 Feb 06 11:41 AM
‎2009 Feb 06 11:43 AM
HI
You can use these function modules to convert measurements
BKKT_BKKTERM_CONVERT_TERMUNIT
BKKT_BKKTERM_CONVERT_UNIT
or
UNIT_CONVERSION_SIMPLE
convert weights from one UOM to another.
Thanks
Viquar Iqbal
‎2009 Feb 06 11:55 AM
Hi experts,
well my main concern is to convert UOM into Tonne When ever it is KG or divide The Kg By 1000 ultimately it should be in tonne
Regards
Sumeet malhotra
‎2009 Feb 06 3:03 PM
Hi Experts,
I am now using the functional module UNIT_CONVERSION_SIMPLE have any one used it first,if yes please provide with the samples. i have to convert tones into kg.
regards
Sumeet Malhotra
‎2009 Feb 07 4:15 AM
Hi Experts,
Have any one used this Function module unit_conversion_simple please help Not getting any reply since tmmrow,I am not able to get the desired output wont to convert all KG inputs into Tonne.
this is the code part
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
INPUT = ERFMG " QUANTITY
NO_TYPE_CHECK = 'X'
ROUND_SIGN = ' '
UNIT_IN = ERFME " ORIGINAL UOM WHICH EXIST
UNIT_OUT = 'TO' " UOM REQUIRED
IMPORTING
ADD_CONST =
DECIMALS =
DENOMINATOR = 1000
NUMERATOR =
OUTPUT = RESULT "OUTPUT
EXCEPTIONS
CONVERSION_NOT_FOUND = 1
DIVISION_BY_ZERO = 2
INPUT_INVALID = 3
OUTPUT_INVALID = 4
OVERFLOW = 5
TYPE_INVALID = 6
UNITS_MISSING = 7
UNIT_IN_NOT_FOUND = 8
UNIT_OUT_NOT_FOUND = 9
OTHERS = 10
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Please help
Thanks
Edited by: sumeet malhotra on Feb 7, 2009 5:46 AM
‎2009 Feb 07 4:50 AM
Hi Summet
There is a problem with the UNIT fm you specified .
It always considers numeric values for the input field as character and throws error
try using CF_UT_UNIT_CONVERSION
Give your quantity in VALUE_OLD_IMP
, UNIT_NEW_IMP as TON
and UNIT_OLD_IMP as KG.
Use the above Fm after checking if the unit is 'KG'.
Edited by: Martina Floriette on Feb 7, 2009 5:52 AM
‎2009 Feb 07 5:00 AM
Hi,
The function module cf_ut_unit_conversionis having first two fields of matnr and meins but i am using table mseg where i am having quantity in mseg_erfmg and unit in Mseg-erfme would it work in this case Plus i am going to call this function module inside a user exit .
EXPORTING
MATNR_IMP = ' '
MEINS_IMP = ' '
Please reply.
Thanks
Sumeet Malhotra
‎2009 Feb 07 5:08 AM
Hi sumeet,
The first two fields are not mandatory .
So jus ignore those fields and proceed further ...
If any issues let me know i d send the code
‎2009 Feb 07 5:21 AM
Hi,
I just left the first two field and the code is as follow.
CALL FUNCTION 'CF_UT_UNIT_CONVERSION'
EXPORTING
MATNR_IMP = MATNR
MEINS_IMP = MEINS
UNIT_NEW_IMP = 'TO'
UNIT_OLD_IMP = 'KG'
VALUE_OLD_IMP = ERFMG
IMPORTING
VALUE_NEW_EXP = ERFMG
EXCEPTIONS
OVERFLOW = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
But when i execute it an error is coming stating Value_old_imp the field rerfmg is of differnt field type.
I am applying this code in j1i5 tcode under the user exit j_1i7_userexit_j1i5_validate for converting the quantity.
Please See it Once.
Thanks
Sumeet Malhotra
‎2009 Feb 07 5:26 AM
HI sumeet,
Try receiving the output in the datatype of the fm field output and then assign the value to your ERFMG field
after you exit your fm .
‎2009 Feb 07 5:33 AM
Hi Sumeet,
Try to check 'Where used list' in ABAP Editor.
May be you get some programs where this FM is used.
Regards,
Amit
‎2009 Feb 07 5:42 AM
Hi,
Again same problem can you just see it by applying to j1i5 that it works or not i assigned the output type to a data type but still same error.
CALL FUNCTION 'CF_UT_UNIT_CONVERSION'
EXPORTING
MATNR_IMP = MATNR
MEINS_IMP = MEINS
UNIT_NEW_IMP = 'TO'
UNIT_OLD_IMP = 'KG'
VALUE_OLD_IMP = ERFMG
IMPORTING
VALUE_NEW_EXP = RESULT "This is defined in the export parameter result like mseg-erfmg
EXCEPTIONS
OVERFLOW = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
RESULT = T_MSEG-ERFMG.
Thanks
Sumeet Malhotra
‎2009 Feb 07 11:36 AM
Hi Martina,
Solved the problem by hardcoding it the function module works in some case but gives problem in certain cases finally solved it,rewarding points
Thanks
Sumeet Malhotra
‎2009 Feb 09 3:35 AM
Hi Sumeet,
Sorry that I was not availbale the other day ....
Could you jus post the code what u ve done to solve that uncertainity problem
and congrats on solving it