this code help u to understand the logic of this fm....
&----
*
*& Form z_unit_conversion_kg
&----
This form is used to convert weight unit in 'LB'
----
--> p1 text
<-- p2 text
----
FORM z_unit_conversion_lb.
i_ln_items-brgew_kg = i_ln_items-brgew.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = i_ln_items-brgew
unit_in = c_kg
unit_out = c_lb
IMPORTING
output = i_ln_items-brgew_lb.
MODIFY i_ln_items TRANSPORTING brgew_kg brgew_lb.
ENDFORM. " z_unit_conversion_lb
&----
*& Form z_unit_conversion_lb
&----
This form is used to convert weight unit in 'KG'
----
--> p1 text
<-- p2 text
----
FORM z_unit_conversion_kg.
i_ln_items-brgew_lb = i_ln_items-brgew.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = i_ln_items-brgew
unit_in = c_lb
unit_out = c_kg
IMPORTING
output = i_ln_items-brgew_kg.
MODIFY i_ln_items TRANSPORTING brgew_lb brgew_kg.
ENDFORM. " z_unit_conversion_kg
&----
*& Form z_unit_conversion_kg_lb
&----
This form is used to convert weight unit in 'KG' and 'LB'
----
--> p1 text
<-- p2 text
----
FORM z_unit_conversion_kg_lb.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = i_ln_items-brgew
unit_in = i_ln_items-gewei
unit_out = c_kg
IMPORTING
output = i_ln_items-brgew_kg.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
input = i_ln_items-brgew_kg
unit_in = c_kg
unit_out = c_lb
IMPORTING
output = i_ln_items-brgew_lb.
MODIFY i_ln_items TRANSPORTING brgew_kg brgew_lb.
ENDFORM. " z_unit_conversion_kg_lb
Sample program.
&----
*& Report ZVTN_CONVERT *
*& *
&----
*& *
*& *
&----
REPORT ZVTN_CONVERT.
data : inputval type i,
outval type i.
inputval = 69.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
INPUT = inputval
NO_TYPE_CHECK = 'X'
ROUND_SIGN = ' '
UNIT_IN = 'KG'
UNIT_OUT = 'LB'
IMPORTING
ADD_CONST =
DECIMALS =
DENOMINATOR =
NUMERATOR =
OUTPUT = outval
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.
write outval.
Add comment