ABAP Keyword Documentation → ABAP − Reference → Processing Internal Data → Assignments → Assignment and Conversion Rules → Conversion Rules for Elementary Data Objects → Character-Like Source Fields
Source Field Type n
The conversion rules are designed in such a way that when data objects of type
n
are assigned to character-like data objects they behave as character-like
data objects. Valid data for data objects of type n
is in the form of digit-only
strings. When assigning valid data to number data objects, the numeric value of the string of digits
is assigned to the target object. The conversion rules, however, also allow assignment of numeric text fields that contain invalid data. The latter is not recommended.
Other versions: 7.31 | 7.40 | 7.54
Numeric Target Fields
Target | Conversion |
---|---|
i , int8 , (b , s ) |
Content is handled in the same way as a source field of type c |
p |
Content is handled in the same way as a source field of type c |
decfloat16 , decfloat34 |
Content is handled in the same way as a source field of type c |
f |
Content is handled in the same way as a source field of type c |
Note
- The class CL_ABAP_DECFLOAT contains the methods READ_DECFLOAT34 and READ_DECFLOAT16, which convert character strings into decimal floating point numbers. The exceptions of these methods are more significant than those of a normal assignment. Furthermore, the methods return a return value that reveals information about the roundings performed.
Example
The result of the following conversion has the value 0.
DATA num4 type n LENGTH 4 VALUE IS INITIAL.
DATA(result) = CONV i( num4 ).
Character-Like Target Fields
Target | Conversion |
---|---|
c |
Content is handled in the same way as a source field of type c |
n |
The characters in the source field are passed right-justified to the target field. Trailing blanksare copied. If the target field is longer than the characters passed, the field is padded with "0" characters from the left. If the target field is shorter, the characters are cut off on the left. |
string |
Content is handled in the same way as a source field of type c |
Example
The string produced by the conversion is 0000001234.
DATA num4 TYPE n LENGTH 4 VALUE '1234'.
TYPES num10 TYPE n LENGTH 10.
DATA(result) = CONV num10( num4 ).
Byte-Like Target Fields
Target | Conversion |
---|---|
x |
The content of the source field is converted first to data type i (seeabove) and then to type x (see conversion table for source field type i , int8 ,(b , s )). |
xstring |
The content of the source field is converted first to data type i (seeabove) and then to type xstring (see conversion table for source field type i , int8 ,(b , s )). |
Example
The byte chain produced by the conversion is 04D2.
DATA num4 TYPE n LENGTH 4 VALUE '1234'.
DATA(result) = CONV xstring( num4 ).
Date/Time Fields as Target Fields
Target | Conversion |
---|---|
d |
Content is handled in the same way as a source field of type c |
t |
Content is handled in the same way as a source field of type c |
utclong |
Not supported. Produces a syntax error or raises the exception CX_SY_CONVERSION_NOT_SUPPORTED. |
Example
The value of the date field produced by the conversion is the unchanged value 20000101 of the source field.
DATA num8 TYPE n LENGTH 8 VALUE '20000101'.
DATA(result) = CONV d( num8 ).