Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing Internal Data →  Assignments →  Assignment and Conversion Rules →  Conversion Rules for Elementary Data Objects →  Numeric Source Fields 

Source Field Type p

If the program attribute fixed point arithmetic is not set, the decimal separator in source fields with the type p is ignored, except in assignments to character-like target fields with the types c and string.

Other versions: 7.31 | 7.40 | 7.54

Numeric Target Fields

Target Conversion
i, int8, (b, s) The value of the packed number is rounded commercially to an integer number. If this number is within thevalue range for the data type i,(b, s), it is converted to the internal representationof the corresponding integer number. If the number is not within this range, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
p The value of the packed number is rounded commercially to the number ofdecimal places ofthe target field. If this number is within the value range for the data type of the target field, itis converted to the internal representation of a packed number. If the number is not within this range, the handleable exception CX_SY_CONVERSION_OVERFLOW is raised.
decfloat16, decfloat34 The value of the packed number is converted into the internal format of a decimal floating pointnumber. If the number of places for a target field of type decfloat16 isgreater than 16 when the assignment is performed, commercial rounding to 16 places is applied. If the mantissa of the target field is long enough, thescaling is set to the number ofdecimal places ofthe source field. An invalid value in the source field raises the handleable exception CX_SY_CONVERSION_NO_NUMBER.
f The value of the packed number is converted into the internal format of a binary floating pointnumber. If the decimal number cannot be represented as a binary floating point number, the nearest value is used. An invalid value in the source field produces undefined behavior.


Example

The result of the following conversion has the value 8.1499999999999995E-01.

DATA pack TYPE p DECIMALS 3 VALUE '0.815'. 

DATA(result) = CONV f( pack ). 

Character-Like Target Fields

Target Conversion
c The value of the packed number is formatted incommercial notation and passed to the target field,flush left. The character "-" is set in the last place for a negative value and a blank is set in thelast place for a positive value. If the target field is longer than the sequence of digits, includingthe sign, the field is padded with blanks on the left. If it is too short, the number representationis moved to the right by one place (in the case of positive values). If the target field is still tooshort (and in the case of negative values), characters are cut off on the left and the character "*" is set in the first place of the target field.
n The value of the packed number is rounded commercially to an integer number. The absolute valueis passed to the target field as a right-justified string of digits. If the target field is longer thanthe string of digits, the field is padded with zeroes on the left. If it is too short, the values on the left are cut off.
string The value of the packed number is formatted incommercial notationand passed to the target field, flush left. The character "-" is set in the last place for a negativevalue and a blank is set in the last place for a positive value. The resulting length of the target field is determined by the number of digits, plus the places for the sign and the decimal separator.


Note

If the number of decimal places in the source field is greater than the number of digits calculated from 2 x the length of dobj - 1, the corresponding number of zeroes is inserted between decimal separators and digits in assignments to data objects of the types c and string and the longer sequence of digits is assigned.


Example

The string produced by the conversion is 123,456-.

DATA pack TYPE p DECIMALS 3 VALUE '-123,456'. 

DATA(result) = CONV string( pack ). 

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 0000007C and matches the result of the conversion of the rounded number 124.

DATA pack TYPE p DECIMALS 3 VALUE '123,999'. 

TYPES hex TYPE x LENGTH 4. 
DATA(result) = CONV hex( pack ). 

Date/Time Fields as Target Fields

Target Conversion
d The content of the source field is converted first to data type i (seeabove) and then to type d (see conversion table for source field type i, int8,(b, s)).
t The content of the source field is converted first to data type i (seeabove) and then to type t (see conversion table for source field type i, int8,(b, s)).
utclong Not supported. Produces a syntax error or raises the exception CX_SY_CONVERSION_NOT_SUPPORTED.


Note

The method TSTMP2UTCLONG of class CL_ABAP_TSTMP converts time stamps in packed numbers to time stamp fields of the type utclong.


Example

The value of the date field produced by the conversion is 20170111.

DATA pack TYPE p VALUE 736341. 

DATA(result) = CONV d( pack ).