SAP UNIT_CONVERSION_SIMPLE Function Module for Measurement unit conversion by table T006, with rounding









UNIT_CONVERSION_SIMPLE is a standard unit conversion simple SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Measurement unit conversion by table T006, with rounding processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.


See here to view full function module documentation and code listing for unit conversion simple FM, simply by entering the name UNIT_CONVERSION_SIMPLE into the relevant SAP transaction such as SE37 or SE38.

Function Group: SCV0
Program Name: SAPLSCV0
Main Program: SAPLSCV0
Appliation area: *
Release date: 14-Mar-2000
Mode(Normal, Remote etc): Normal Function Module
Update:



Function UNIT_CONVERSION_SIMPLE pattern details

In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'"Measurement unit conversion by table T006, with rounding
EXPORTING
INPUT = "Input Value
* NO_TYPE_CHECK = 'X' "Conversion factor type check
* ROUND_SIGN = ' ' "Rounding flag (+ up, - down, X comm.)
* UNIT_IN = ' ' "Unit of input value
* UNIT_OUT = ' ' "Unit of output value

IMPORTING
ADD_CONST = "additive constant for conversion
DECIMALS = "Number of decimal places for rounding
DENOMINATOR = "Denominator for conversion
NUMERATOR = "Numerator for conversion
OUTPUT = "Output value

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
.



IMPORTING Parameters details for UNIT_CONVERSION_SIMPLE

INPUT - Input Value

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

NO_TYPE_CHECK - Conversion factor type check

Data type:
Default: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)

ROUND_SIGN - Rounding flag (+ up, - down, X comm.)

Data type:
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

UNIT_IN - Unit of input value

Data type: T006-MSEHI
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

UNIT_OUT - Unit of output value

Data type: T006-MSEHI
Default: SPACE
Optional: Yes
Call by Reference: No ( called with pass by value option)

EXPORTING Parameters details for UNIT_CONVERSION_SIMPLE

ADD_CONST - additive constant for conversion

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

DECIMALS - Number of decimal places for rounding

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

DENOMINATOR - Denominator for conversion

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

NUMERATOR - Numerator for conversion

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

OUTPUT - Output value

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

EXCEPTIONS details

CONVERSION_NOT_FOUND - Conversion factor could not be determined

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

DIVISION_BY_ZERO - Division by zero caught

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

INPUT_INVALID - Input value is not a number

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

OUTPUT_INVALID - OUTPUT parameter is not a number

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

OVERFLOW - Field overflow

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

TYPE_INVALID - an output parameter is not a number

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

UNITS_MISSING - no units specified

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

UNIT_IN_NOT_FOUND - UNIT_IN is not maintained

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

UNIT_OUT_NOT_FOUND - UNIT_OUT is not maintained

Data type:
Optional: No
Call by Reference: No ( called with pass by value option)

Copy and paste ABAP code example for UNIT_CONVERSION_SIMPLE Function Module

The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.

DATA:
lv_input  TYPE STRING, "   
lv_add_const  TYPE STRING, "   
lv_conversion_not_found  TYPE STRING, "   
lv_decimals  TYPE STRING, "   
lv_no_type_check  TYPE STRING, "   'X'
lv_division_by_zero  TYPE STRING, "   
lv_round_sign  TYPE STRING, "   SPACE
lv_denominator  TYPE STRING, "   
lv_input_invalid  TYPE STRING, "   
lv_unit_in  TYPE T006-MSEHI, "   SPACE
lv_numerator  TYPE T006, "   
lv_output_invalid  TYPE T006, "   
lv_output  TYPE T006, "   
lv_overflow  TYPE T006, "   
lv_unit_out  TYPE T006-MSEHI, "   SPACE
lv_type_invalid  TYPE T006, "   
lv_units_missing  TYPE T006, "   
lv_unit_in_not_found  TYPE T006, "   
lv_unit_out_not_found  TYPE T006. "   

  CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'  "Measurement unit conversion by table T006, with rounding
    EXPORTING
         INPUT = lv_input
         NO_TYPE_CHECK = lv_no_type_check
         ROUND_SIGN = lv_round_sign
         UNIT_IN = lv_unit_in
         UNIT_OUT = lv_unit_out
    IMPORTING
         ADD_CONST = lv_add_const
         DECIMALS = lv_decimals
         DENOMINATOR = lv_denominator
         NUMERATOR = lv_numerator
         OUTPUT = lv_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
. " UNIT_CONVERSION_SIMPLE




ABAP code using 7.40 inline data declarations to call FM UNIT_CONVERSION_SIMPLE

The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.

 
 
 
 
DATA(ld_no_type_check) = 'X'.
 
 
DATA(ld_round_sign) = ' '.
 
 
 
"SELECT single MSEHI FROM T006 INTO @DATA(ld_unit_in).
DATA(ld_unit_in) = ' '.
 
 
 
 
 
"SELECT single MSEHI FROM T006 INTO @DATA(ld_unit_out).
DATA(ld_unit_out) = ' '.
 
 
 
 
 


Search for further information about these or an SAP related objects



Comments on this SAP object

What made you want to lookup this SAP object? Please tell us what you were looking for and anything you would like to be included on this page!