Skip to Content
Former Member
Oct 22, 2014 at 09:33 PM

cl_abap_structdescr finding data element descriptions of program defined structure


I have an program built structure (not ddic). with several fields, all defined with ddic data elements.

BEGIN OF ty_selected,
material TYPE matnr,
matl_type TYPE mtart,
lab_office TYPE labor,
plant TYPE werks_d,
status TYPE mmsta,
END OF ty_selected.
DATA: gs_selected type ty_selected.

I want to retrieve the description text of the data elements that are in this structure. I just can't seen to get it. I figured it out for ddic structures but not program defined ones.

For ddic structures I am using class cl_abap_structdescr like this:

DATA: ref_struct TYPE REF TO cl_abap_structdescr,
ls_struct TYPE zmatl, " ddic type
lt_ddic_info TYPE ddfields,
w_head TYPE ty_return.
<ddic_info> TYPE LINE OF ddfields.

ref_struct ?= cl_abap_typedescr=>describe_by_data( ls_struct ).
lt_ddic_info = ref_struct->get_ddic_field_list( ).

LOOP AT lt_ddic_info ASSIGNING <ddic_info>.
MOVE <ddic_info>-fieldname TO w_head-fieldname.
MOVE <ddic_info>-fieldtext TO w_head-fieldtext.
APPEND w_head TO f_return.

I figure there should be something similar I can do for program defined structures, but no joy.

Can anyone help me please?