Is it possible to find out the TABLE-FIELD phrase from a variable?
In the example below, how do I get jkak-vbeln
as a type from dref
as a string?
I tried some RTTI but didn't find anything useful.
DATA: p_dat TYPE jkak-vbeln.
DATA: dref TYPE REF TO data.
GET REFERENCE OF p_dat INTO dref.
This answer is for getting at runtime the text JKAK-VBELN
from a variable declared with DATA p_dat TYPE jkak-vbeln
, i.e. for getting its type name in full text. This answer works well for types based on ABAP Dictionary (DDIC) "TABLE-FIELD" combination, I don't know for anything else.
RTTI is only interested by the technical type, not by the exact path of its origin, so you can't do it fully with RTTI.
If the type of the variable comes from the DDIC, then you can use DESCRIBE FIELD ... HELP-ID .... Assuming that your starting point is your DREF
reference to that variable, here is how to use it:
DATA: p_dat TYPE jkak-vbeln.
DATA: dref TYPE REF TO data.
GET REFERENCE OF p_dat INTO dref.
DATA: help_id TYPE string.
FIELD-SYMBOLS: <any> TYPE any.
ASSIGN dref->* TO <any>.
DESCRIBE FIELD <any> HELP-ID help_id.
ASSERT help_id = 'JKAK-VBELN'.
If your goal is to scan your ABAP source code, then you can use READ REPORT, but you have many more things to think about, like using a lexer, a parser, reading the parent or child ABAP source code units, etc.