Get Example source ABAP code based on a different SAP table
ID UNPACK • UNPACK ABAP Statement • TO UNPACK
UNPACK> Short Reference >
ABAP_SYNTAX UNPACK source TO destination.>
What does it do? This statement converts the content of the data object source> in accordance with special rules and assigns the converted content to the data object destination>. source> expects the data type p> of length 16 without decimal places> and no operands of data type decfloat16> or decfloat34> can be used. The data type of destination> must be character-like and flat>. The conversion is performed according to the following rules:
If the data type of source> is not of type p> with length 16 and without decimal places, the content of source> is converted to this data type. Contrary to the rules described in Conversion Rules for Elementary Data Types>, any decimal separator in source> is completely ignored.
The digits of the interim result are assigned as right-aligned digits to the data object destination> and without a plus/minus sign. Any surplus places in destination> are padded with zeros on the left. If the length of destination> is not sufficient, it is truncated on the left.
Latest notes:
The function of the statement UNPACK> is based on the fact that the BCD> representation of a place> corresponds to the second half byte of code of a digit in most character representations. This conversion is generally known as Unpacking>.
The statement PACK>> used for packing is obsolete and can be replaced by a regular assignment>. ABAP_HINT_END
Example ABAP Coding
After the assignments, char1> and char2> contain the values 123,456> and 0000123456>. ABEXA 00752 ABAP_EXAMPLE_END
Runtime Exceptions
Catchable Exceptions CX_SY_CONVERSION_NO_NUMBER>>
Reason for error:
Source field cannot be interpreted as a number
Runtime error:
CONVT_OVERFLOW> CX_SY_CONVERSION_OVERFLOW>>
Reason for error:
Overflow during conversion (type p>)
Runtime error:
BCD_OVERFLOW>
Non-catchable Exceptions
Reason for error:
Source field (type p>) contains an incorrect BCD format