Dears,
I have a field in a custom table of type DEC length 20 decimals 2.
At run time, this field is converting to type P length 11 decimals 2.
Why is this occurring and how can I correct it?
The statements in the program were as follows:
date:
Tg_geral TYPE TABLE OF ztfid_geral,
Eg_geral TYPE ztfid_geral,
FIELD-SYMBOLS: <fs1> TYPE any,
<Fs_field> TYPE any,
ASSIGN eg_geral TO <fs1>.
OF.
ASSIGN COMPONENT sy-index OF STRUCTURE <fs1> TO <fs_field>.
- - - - -
ENDDO
http://help.sap.com/abapdocu_751/en/index.htm?file=abenddic_builtin_types_int_pack.htm
"An odd number of places should be used in the definition of data types based on the built-in type DEC."
In ABAP, "type P length 11" means 11 bytes for storing the number, one digit being stored in one half byte, and the sign in one half byte. So, it can store up to 21 digits. "decimals 2" means 2 digits of the 21 digits are reserved for the digits after the decimal point.
In the ABAP dictionary, DEC of length 20 means 20 digits. But ABAP can store only an "odd number of places" (cf Horst answer), so the corresponding ABAP type will contain 21 digits i.e. in 11 bytes.