Jagger
Jagger

Reputation: 10524

DESCRIBE FIELD with an unassigned field symbol

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.

Upvotes: 6

Views: 1381

Answers (1)

vwegert
vwegert

Reputation: 18483

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.

Upvotes: 5

Related Questions