Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DESCRIBE FIELD with an unassigned field symbol

Tags:

abap

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.

like image 606
Jagger Avatar asked Oct 27 '15 10:10

Jagger


People also ask

How do you unassign a field symbol?

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.

How do you define a field symbol?

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.

How do you assign a structure to a field symbol?

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.

What are field symbols and field groups?

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.


1 Answers

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.

like image 129
vwegert Avatar answered Sep 23 '22 02:09

vwegert