Type Value Area Initial Value
c Any alphanumeric character " " for every position
i -2.147.483.648 to +2.147.483.647 0
n Any alphanumeric characters, however, valid values are
Notes
The system class CL_ABAP_EXCEPTIONAL_VALUES contains methods that return the minimum and maximum value for a data object (as of release 6.10).
As the decimal places of a floating point number of type f are represented internally as dual fractions, there is not an exact equivalent for every number that can be represented in the decimal system. This can lead to rounding errors in assignments and intermediate results of calculations. These errors can be avoided by using a two-step rounding procedure.
For data objects of data type p, the program attribute fixed point arithmetic must be set so that the decimal separator is taken into account. Otherwise, the content is handled as if there is no decimal separator, in all operations except for displaying a list.
Example
According to the formula in the table, the value area of a packed number with length 2 and two decimal places is (-10^{(2x2 -1) +1) / (10}2) bis (+10^{(2x2 -1) -1) / (10}2) and therefore =-9.99 to +9.99 in steps of 0.01. A value within this range, for example, 1.428, is rounded up to 1.43.
DATA: pack(2) TYPE p DECIMALS 2,
result TYPE REF TO data.
FIELD-SYMBOLS <result> TYPE ANY.
result = cl_abap_exceptional_values=>get_min_value( pack ).
IF result IS NOT INITIAL.
ASSIGN result->* TO <result>.
WRITE <result>.
ENDIF.
result = cl_abap_exceptional_values=>get_max_value( pack ).
IF result IS NOT INITIAL.
ASSIGN result->* TO <result>.
WRITE <result>.
ENDIF.
Type Description DL Initial value
C Character 1 Space
N Numeric text 1 '00...0'
D Date YYYYMMDD 8 '00000000'
T Time HHMMSS 6 '000000'
X Byte (heXadecimal) 1 X'00'
I Integer 4 0
P Packed number 8 0
F Floating point number 8 '0.0'
Sample Code:
DATA: ws_data TYPE char10.
ws_data = 'SAMPLE'.
WRITE:/ ws_data.
DATA: ws_data1 TYPE i.
ws_data1 = 10.
WRITE:/ ws_data1.
DATA: ws_data2 TYPE n LENGTH 2.
ws_data2 = 31.
WRITE:/ ws_data2.
Regards,
Prakash.
Add a comment