Ansicht
Dokumentation

UNIT_QUANTITY_SWITCH - Convert set to next suitable measurement unit

UNIT_QUANTITY_SWITCH - Convert set to next suitable measurement unit

Addresses (Business Address Services)   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

This function module converts an input value of type F into an output value of type P with any number of decimal places, whereby the quantity is automatically converted into the next appropriate unit in the same dimension and measurement unit family if field overflow or too large a rounding error occur.

If the rounding error is too big, the conversion uses a smaller measurement unit (e.g. from km to m).

If the input value is too big for the output value (field overflow), the uses a larger measurement unit (e.g. from m to km). If the value is too big even for the largest measurement unit, 'X' is set in the parameter OVERFLOW and the maximum value in the parameter OUTPUT.

The accepted rounding error can be specifed in the parameter TOLERANCE. The relative variance is checked against the inverse of this parameter.

If, e.g. the value of TOLERANCE = 1000 and the rounding error is greater 1/1000, the conversion uses a smaller unit.

Example:
The value 1,004 M is to be put in a field with two decimal places. There is a rounding error of (1,004 - 1) / 1,004, which is approximately 4/1000. In this case the conversion is to cm and the rounding error is eliminated (100,40 cm).

If no input value measurement unit is passed, the SI unit is assumed.

If no output value measurement unit is passed, the conversion tries to remain in the input value measurement unit.

Example

The value F_VALUE is to be passed to the field P_VALUE. The rounding error is to be < 0,1 % (1/1000).

data:
f_value type f,
ind_overflow(1) type c
p_value type p decimals 3,
tol type i value 1000,
unit_in like t006-msehi,
unit_out like t006-msehi.
...
call function 'UNIT_QUANTITY_SWITCH'
exporting
imp_unit = unit_in
imp_value = f_value
tolerance = tol
importing
exp_value = p_value
overflow = ind_overflow
changing
exp_unit = unit_out
exceptions
type_not_p = 01
unit_not_found = 02.

Notes

Further information





Parameters

EXP_UNIT
EXP_VALUE
IMP_UNIT
IMP_VALUE
OVERFLOW
TOLERANCE

Exceptions

DIFFERENT_DIMENSIONS
OUTPUT_NOT_TYPE_P
UNIT_NOT_FOUND

Function Group

SCV0

BAL_S_LOG - Application Log: Log header data   PERFORM Short Reference  
This documentation is copyright by SAP AG.

Length: 2707 Date: 20240523 Time: 141038     sap01-206 ( 47 ms )