[ABAP] Customizing-Objekte zu einem Datenfeld lesen

TYPES : BEGIN OF ty_s_customizing_tables,
          tabname TYPE dd02l-tabname,
          ddtext  TYPE dd02t-ddtext,
        END OF ty_s_customizing_tables.

TYPES: ty_it_customizing_tables TYPE STANDARD TABLE OF ty_s_customizing_tables WITH DEFAULT KEY.

DATA: it_customizing_tables TYPE ty_it_customizing_tables.

* Klasse für Eventhandling definieren
CLASS lcl_events DEFINITION.
  PUBLIC SECTION.
* Doppelklick
    CLASS-METHODS: on_double_click FOR EVENT double_click OF cl_salv_events_table
      IMPORTING
          row
          column
          sender.
ENDCLASS.

CLASS lcl_events IMPLEMENTATION.
  METHOD on_double_click.
* Tabelle / Pflegeview
    DATA(lv_tab) = CONV dd02l-tabname( it_customizing_tables[ row ]-tabname ).

* Customizingobjekte zu Tabelle anzeigen, ins SAP-IMG abspringen
    CALL FUNCTION 'OBJECT_MAINTENANCE_CALL'
      EXPORTING
        tabname                        = lv_tab
      EXCEPTIONS
        interface_not_correct          = 1
        transaction_not_maintained     = 2
        transaction_not_found          = 3
        table_not_activ                = 4
        table_not_found                = 5
        subobject_not_found_in_project = 6
        subobject_not_found_in_guide   = 7
        object_not_found_in_project    = 8
        object_not_found_in_guide      = 9
        table_has_no_object_in_project = 10
        table_has_no_object_in_guide   = 11
        outline_not_found              = 12
        call_transaction_recurring     = 13
        system_failure                 = 14
        OTHERS                         = 15.

    DATA(lv_err) = ||.

    CASE sy-subrc.
      WHEN 1.
        lv_err = |INTERFACE_NOT_CORRECT|.
      WHEN 2.
        lv_err = |TRANSACTION_NOT_MAINTAINED|.
      WHEN 3.
        lv_err = |TRANSACTION_NOT_FOUND|.
      WHEN 4.
        lv_err = |TABLE_NOT_ACTIV|.
      WHEN 5.
        lv_err = |TABLE_NOT_FOUND|.
      WHEN 6.
        lv_err = |SUBOBJECT_NOT_FOUND_IN_PROJECT|.
      WHEN 7.
        lv_err = |SUBOBJECT_NOT_FOUND_IN_GUIDE|.
      WHEN 8.
        lv_err = |OBJECT_NOT_FOUND_IN_PROJECT|.
      WHEN 9.
        lv_err = |OBJECT_NOT_FOUND_IN_GUIDE|.
      WHEN 10.
        lv_err = |TABLE_HAS_NO_OBJECT_IN_PROJECT|.
      WHEN 11.
        lv_err = |TABLE_HAS_NO_OBJECT_IN_GUIDE|.
      WHEN 12.
        lv_err = |OUTLINE_NOT_FOUND|.
      WHEN 13.
        lv_err = |CALL_TRANSACTION_RECURRING|.
      WHEN 14.
        lv_err = |SYSTEM_FAILURE|.
      WHEN 15.
        lv_err = |OTHERS|.
    ENDCASE.

    MESSAGE |{ lv_err }| TYPE 'S' DISPLAY LIKE 'E'.

  ENDMETHOD.
ENDCLASS.

SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (10) l_field FOR FIELD p_field.
PARAMETER: p_field TYPE dd03vv-fieldname DEFAULT 'VSBED'.
SELECTION-SCREEN END OF LINE.

INITIALIZATION.

  l_field = 'Feldname:'.

START-OF-SELECTION.

* Customizingtabellen zu einem Datenfeld lesen
  SELECT t~tabname,
         tx~ddtext
    FROM dd03vv AS t
    INNER JOIN dd02l AS c ON t~tabname = c~tabname
    INNER JOIN dd02t AS tx ON t~tabname = tx~tabname
    INTO TABLE @it_customizing_tables
    WHERE t~fieldname = @p_field     " Feldname
      AND t~tabclass = 'TRANSP'      " transparente Tabellen
      AND t~as4local = 'A'           " aktive Objekte
      AND c~contflag IN ('C', 'G')   " Typ: Customizing-Tabellen
      AND tx~ddlanguage = @sy-langu. " Anmeldesprache

  TRY.
* SALV-Table
      DATA: o_salv TYPE REF TO cl_salv_table.

      cl_salv_table=>factory( IMPORTING
                                r_salv_table   = o_salv
                              CHANGING
                                t_table        = it_customizing_tables ).

* Grundeinstellungen
      o_salv->get_functions( )->set_all( abap_true ).
      o_salv->get_columns( )->set_optimize( abap_true ).
      o_salv->get_display_settings( )->set_list_header( |Customizing-Tabellen zu Datenfeld { p_field } (Doppelklick -> IMG)| ).
      o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
      o_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

* Spaltenüberschriften: technischer Name und Beschreibungstexte
      LOOP AT o_salv->get_columns( )->get( ) ASSIGNING FIELD-SYMBOL(<c>).
        DATA(o_col) = <c>-r_column.
        o_col->set_short_text( || ).
        o_col->set_medium_text( || ).
        o_col->set_long_text( |{ o_col->get_columnname( ) } [{ o_col->get_long_text( ) }]| ).
      ENDLOOP.

* Handler registrieren
      SET HANDLER lcl_events=>on_double_click FOR o_salv->get_event( ).

      o_salv->display( ).
    CATCH cx_root INTO DATA(e_txt).
      WRITE: / e_txt->get_text( ).
  ENDTRY.

Links

[ABAP] Tabellen zu einer Transaktion auflisten

TYPES: BEGIN OF ty_data_item,
         tcode    TYPE tstc-tcode,
         ttext    TYPE tstct-ttext,
         pgmna    TYPE tstc-pgmna,
         tabname  TYPE d010tab-tabname,
         tabclass TYPE dd02l-tabclass,
         ddtext   TYPE dd02t-ddtext,
       END OF ty_data_item.

DATA: it_data TYPE STANDARD TABLE OF ty_data_item WITH DEFAULT KEY.

PARAMETERS: ptcode TYPE tstc-tcode DEFAULT 'MIGO'.
PARAMETERS: plang TYPE dd02t-ddlanguage DEFAULT 'DE'.

START-OF-SELECTION.

* Holt Transaktion, Programm zur Transaktion, verwendete Tabellen im Programm
  SELECT tstc~tcode, tstct~ttext, tstc~pgmna, d010tab~tabname, dd02l~tabclass, dd02t~ddtext
    FROM tstc
      INNER JOIN d010tab ON d010tab~master = tstc~pgmna
      INNER JOIN dd02l ON dd02l~tabname = d010tab~tabname
      INNER JOIN dd02t ON dd02t~tabname = dd02l~tabname
      INNER JOIN tstct ON tstct~tcode = tstc~tcode
      INTO CORRESPONDING FIELDS OF TABLE @it_data
      WHERE tstc~tcode = @ptcode
      AND dd02t~ddlanguage = @plang
      AND tstct~sprsl = @plang.

  SORT: it_data BY tabclass DESCENDING tabname.

  DATA: o_salv TYPE REF TO cl_salv_table.

  cl_salv_table=>factory( IMPORTING
                            r_salv_table = o_salv
                          CHANGING
                            t_table = it_data ).

  o_salv->get_functions( )->set_all( abap_true ).
  o_salv->get_display_settings( )->set_striped_pattern( abap_true ).
  o_salv->get_columns( )->set_optimize( abap_true ).

  o_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ).

  o_salv->display( ).