Gross Weight in Kilograms
CLEAR RESULT.
DATA: WEIGHT LIKE COMM_STRUCTURE-GROSS_WGT.
IF COMM_STRUCTURE-UNIT_OF_WT NE 'KG'.
WEIGHT = COMM_STRUCTURE-GROSS_WGT.
CALL FUNCTION 'UNIT_CONVERSION_SIMPLE'
EXPORTING
INPUT = COMM_STRUCTURE-GROSS_WGT
UNIT_IN = COMM_STRUCTURE-UNIT_OF_WT
UNIT_OUT = 'KG'
IMPORTING
OUTPUT = WEIGHT
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 NE 0.
CLEAR MONITOR.
MONITOR-msgno = '009'.
MONITOR-msgid = 'SDBW'.
MONITOR-msgty = c_msgty_e.
MONITOR-msgv1 = COMM_STRUCTURE-UNIT_OF_WT.
append MONITOR.
RETURNCODE = 4.
WEIGHT = 0.
ELSE.
RESULT = WEIGHT.
RETURNCODE = 0.
ENDIF.
ELSE.
RESULT = COMM_STRUCTURE-GROSS_WGT.
RETURNCODE = 0.
ENDIF.
IF COMM_STRUCTURE-DOC_CATEG CA DEB_CRED.
RESULT = RESULT * ( -1 ).
ENDIF.