Here is one for you.
Why does the following piece of code not end with a short dump GETWA_NOT_ASSIGNED
and instead return type C
with length 2
?
FIELD-SYMBOLS: <fs_any> TYPE any.
DESCRIBE FIELD <fs_any>
TYPE DATA(l_type)
LENGTH DATA(l_length) IN BYTE MODE
DECIMALS DATA(l_decimals).
I could not find anything in the ABAP documentation about this behaviour.
EDIT:
It looks like the short dump is never to be expected. I tried it also with
FIELD-SYMBOLS: <fs_any> TYPE i.
and
FIELD-SYMBOLS: <fs_any> TYPE but000.
so vwegert's answer looks to be plausible, because declaring a variable without any type like that DATA: var.
defaults it to c
with length 1
.
UNASSIGN - ABAP Keyword Documentation. UNASSIGN <fs>. This statement initializes the field symbol <fs>. After the statement, the field symbol does not reference a memory area and the predicate expression <fs> IS ASSIGNED is false.
Field symbol is a placeholder for data object, which points to the value present at the memory address of a data object. It does not reserve any physical memory space when we declare them. It only points to a data object at run time.
ASSIGN COMPONENT comp OF STRUCTURE struc TO <fs>. to assign one of its components comp to the field symbol <fs>. You can specify the component compeither as a literal or a variable.
Field symbols: are placeholders or symbolic names for other fields. They do not physically reserve space for a field, but point to its contents. A field symbol cam point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.
Personal opinion, not backed by documentation either: Since DATA foo.
will create a variable of TYPE C LENGTH 1
implicitly, this is what DESCRIBE FIELD
does return in this case. You're probably on a Unicode system - on my system, it returns length 1. I'd say you've triggered some undocumented behavior, maybe even a bug. I'd strongly suggest NOT to rely on this - I suppose it might be changed at any time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With