Hi Folks,
I have a requirement to get the labels for fields in a locally defined structure, something like this:
TYPES: BEGIN OF ty_out,
kunnr TYPE kna1-kunnr,
vkorg TYPE knvv-vkorg,
vtweg TYPE knvv-vtweg,
kukla TYPE kna1-kukla,
vtext TYPE tkukt-vtext,
pltyp TYPE knvv-pltyp,
.....
END of ty_out.
All the fields in the structure are typed based on existing SAP table fields.
I'd like to make use of function module DDIF_FIELDINFO_GET (unless there's an equivalent class method for this?) to get the field descriptions via the returned table dfies_tab:
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = i_tablename
fieldname = i_fieldname
langu = sy-langu
TABLES
dfies_tab = lt_dfies
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
IF sy-subrc EQ 0.
READ TABLE lt_dfies INTO ls_dfies INDEX 1.
IF sy-subrc EQ 0.
r_descr = ls_dfies-scrtext_m.
ELSE.
r_descr = i_fieldname.
ENDIF.
ELSE.
r_descr = i_fieldname.
ENDIF.
I already searched for suitable methods to get the table- and fieldname based on the structure but haven't been lucky. The closest I got was using cl_abap_typedescr=>describe_by_data but that just returns the fieldname and actual type and length of the field. Is there a comparable straightforward method which goes "one step further" and also returns what comes after TYPE but split into tablename and fieldname?
For now - and to be able to test my program quickly, I did it the "hard way" by providing i_tablename and i_fieldname like this (which I don't really like - esp. as the structure is fairly large):
get_field_descr( EXPORTING i_tablename = 'KNA1'
i_fieldname = 'KUNNR'
RECEIVING r_descr = lv_descr ).
I'd like to stick with a locally defined structure as it's only needed for one program so there's no real reason to define it in the dictionary (we have a bit of an "interesting" process for DDIC-changes so try to avoid them as much as possible, in case you are wondering why I mention this).
We are on NW750 with EHP8.
Cheers
Baerbel