Skip to content

Latest commit

 

History

History
237 lines (160 loc) · 2.75 KB

File metadata and controls

237 lines (160 loc) · 2.75 KB

Determining the Conversion Factors

Use method UNIT_PARAMETERS_GET to determine the data conversion factors of a unit.


Parameter Name

Value Help

UNIT

Unit of measurement


Parameter Name

Value Help

DECIMALS 

Number of decimal places for rounding

DIMENSION

Dimension key

NUMERATOR

Numerator for conversion to SI unit

DENOMINATOR

Denominator for conversion to SI unit

EXPONENT

Base ten exponent for conversion to SI unit

ADD_CONST

Additive constant for conversion to SI unit

DECAN

Number of decimal places for number display

FAMUNIT

Unit of measurement family


Exception Name

Value Help

UNIT_NOT_FOUND

Unit of measurement is not maintained

Sample Code:

CLASS zcl_uom_conversion DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC.
 
  PUBLIC SECTION.
     INTERFACES if_oo_adt_classrun.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.
 
CLASS zcl_uom_conversion IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
     DATA(lo_unit) = cl_uom_conversion=>create( ).
    lo_unit->unit_parameters_get(
      EXPORTING
        unit           = 'G'
      IMPORTING
        decimals       = DATA(lv_decimal)
        dimension      = DATA(lv_dimension)
        numerator      = DATA(lv_numerator)
        denominator    = DATA(lv_denominator)
      EXCEPTIONS
        unit_not_found = 1
        OTHERS         = 2 ).
    
    IF sy-subrc = 0.
      out->write( lv_dimension ).
      out->write( lv_decimal ).
      out->write( lv_numerator ).
      out->write( lv_denominator ).
    ENDIF.
  ENDMETHOD.
ENDCLASS.