Tuesday, March 31, 2020

Get structure names used in a database table

Aim:
To get the structure name of the .INCLUDE structures used in a database table.
Tip: Navigate to PRECFIELD field in the output to see the Structure name of the include

Report:
REPORT zag_test_extract_structures.

PARAMETERS: p_table TYPE tabname16 DEFAULT 'EKKO'.

DATA: lt_fields TYPE TABLE OF dd03p,
      lv_name   TYPE ddobjname.
DATA(lref_structype) = cl_abap_typedescr=>describe_by_name( p_table ).
lv_name = p_table.

CALL FUNCTION 'DDIF_TABL_GET'
  EXPORTING
    name          = lv_name
  TABLES
    dd03p_tab     = lt_fields
  EXCEPTIONS
    illegal_input = 1
    OTHERS        = 2.
IF sy-subrc = 0.
  CALL METHOD cl_demo_output=>display_data
    EXPORTING
      value = lt_fields
      name  = 'Navigate to PRECFIELD field to see the Structure name of the include'.
ELSE.
  WRITE 'Error'.
ENDIF.


<End of Document>