Application Development and Automation Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Surendra_Karma
Explorer
0 Kudos
1,202

After an extensive search for a suitable program to effectively display program tables, I decided to take matters into my own hands. Through careful planning and execution, I've developed a small custom solution that streamlines the process of identifying tables necessary for generating tailored reports to meet the unique needs of each customer. I welcome any further suggestions or feedback on this endeavor.

Code listing for: ZCUST_TCODE_TO_TABLES
Description: Program to get TABLES used in a TCODE


*&---------------------------------------------------------------------*
*& Report ZCUST_TCODE_TO_TABLES
*&---------------------------------------------------------------------*
*& Owner        : Surendra Karma
*& Note         : This is just a test program. I'm writing as per my
*&                understanding. This can not guarantee that all the
*&                tables are captured. Suggestions are always Appreciated!
*&---------------------------------------------------------------------*
REPORT zcust_tcode_to_tables.

DATA: lv_tcode TYPE tstc-tcode.
SELECT-OPTIONS: s_tcode FOR lv_tcode NO INTERVALS OBLIGATORY.
PARAMETERS : c_transp AS CHECKBOX,
             c_inttab AS CHECKBOX,
             c_view   AS CHECKBOX,
             c_append AS CHECKBOX,
             c_all    AS CHECKBOX DEFAULT abap_true.

AT SELECTION-SCREEN OUTPUT.
  IF s_tcode IS NOT INITIAL.
    SELECT COUNT( * ) FROM tstc UP TO 1 ROWS WHERE tcode IN @s_tcode.
    IF sy-subrc <> 0.
      MESSAGE 'Please enter a valid t-code' TYPE 'I' DISPLAY LIKE 'E'.
    ENDIF.
  ENDIF.

START-OF-SELECTION.
  SELECT tstc~tcode,
         tstct~ttext,
         tstc~pgmna,
         d010tab~tabname,
         dd02l~tabclass,
         dd02l~sqltab,
         dd02t~ddtext
     FROM tstc AS tstc
     INNER JOIN tstct AS tstct ON tstct~tcode = tstc~tcode
     INNER JOIN d010tab AS d010tab ON d010tab~master = tstc~pgmna
     INNER JOIN dd02l AS dd02l ON dd02l~tabname = d010tab~tabname
     INNER JOIN dd02t AS dd02t ON dd02t~tabname = d010tab~tabname
     INTO TABLE @DATA(lt_data)
     WHERE tstc~tcode IN @s_tcode
       AND dd02t~ddlanguage = 'E'
  AND tstct~sprsl = 'E'.
  IF sy-subrc = 0.
    SORT lt_data BY tcode tabclass tabname DESCENDING.
    IF c_all IS INITIAL.
      IF c_transp IS INITIAL.
        DELETE lt_data WHERE tabclass = 'TRANSP'.
      ENDIF.
      IF c_inttab IS INITIAL.
        DELETE lt_data WHERE tabclass = 'INTTAB'.
      ENDIF.
      IF c_view IS INITIAL.
        DELETE lt_data WHERE tabclass = 'VIEW'.
      ENDIF.
      IF c_append IS INITIAL.
        DELETE lt_data WHERE tabclass = 'APPEND'.
      ENDIF.
    ENDIF.
  ENDIF.

  DATA lo_salv TYPE REF TO cl_salv_table.

  TRY.
      cl_salv_table=>factory(
        IMPORTING
          r_salv_table   = lo_salv
        CHANGING
          t_table        = lt_data
      ).
    CATCH cx_salv_msg INTO DATA(lo_excp). " ALV: General Error Class with Message
MESSAGE lo_excp TYPE 'E' DISPLAY-LIKE 'I'. ENDTRY. lo_salv->get_functions( )->set_all( abap_true ). lo_salv->get_display_settings( )->set_striped_pattern( abap_true ). lo_salv->get_columns( )->set_optimize( abap_true ). lo_salv->get_selections( )->set_selection_mode( if_salv_c_selection_mode=>row_column ). lo_salv->display( ). *Selection texts *---------------------------------------------------------- * C_ALL All tables/structure * C_APPEND Append structures * C_INTTAB Internal tables/Structures * C_TRANSP Transparent tables * C_VIEW Views * S_TCODE Transaction Codes *Messages *---------------------------------------------------------- * Message class: Hard coded

Extracted by Direct Download Enterprise version 1.3.1 - E.G.Mellodew. 1998-2005 UK. Sap Release 757

1 Comment
Labels in this area