Skip to Content

A few days back I got a requirement to add the names of the tables at the top of every custom program (as comments). It was hard to first get the name of the program using T-Code and for every program check the used tables names, so I tried to develop an application to get table names giving the T-Code as input or on the other hand after providing the table name get the T-Codes where this table is being used. I have successfully completed this one.

In the screen shot bellow I am giving the T-Code SP01 and SP02 and it is showing the tables. After click on the table name or description it will open the table same for T-Code.

Selection Screen

image

Output

image

Create a new program using T-Code SE38 copy past bellow code and save it after activation it will be ready to work with

Code

To report this post you need to login first.

12 Comments

You must be Logged on to comment or reply to a post.

  1. Jason Stratham
    To be honest, adding a list of tables used into the header of a program is not the best idea.
    Transacftion SE80 will display all the associated dictionary entries for a given program, so why bloat the program header with this needless information. Just goto SE90 to see the program behind the transaction, then edit the program via se80.

    The only use for such a program might be to create a cross program map to identify all the programs that access tables. We once did this manually for all Z programs as a prerequisite for an upgrade and to help in resolving lengthy table locking issues.  

    (0) 
  2. Anmol Bhat
    Hi,
      For a particular T-Code, for ex: VA01  many programs are used.
    Is there any way to know the program name also where the tables are used.

    (0) 
  3. Daniel Zapardiel
    Hi,

    the code is very usefull but tables used in module functions are not shown.

    The following code show tables used in module funcions (group function) in a transaction.

    SELECT tstct~tcode tstct~ttext d010tab~tabname dd02l~tabclass
    dd02t~ddtext
        INTO CORRESPONDING FIELDS OF TABLE it_detail

        FROM tstc INNER JOIN tstct    ON ( tstc~tcode = tstct~tcode )
                  INNER JOIN cross    ON ( tstc~pgmna = cross~include )
                  INNER JOIN tfdir    ON ( cross~name = tfdir~funcname )
                  INNER JOIN d010tab  ON ( tfdir~pname = d010tab~master )
                  INNER JOIN dd02l    ON ( d010tab~tabname = dd02l~tabname )
                  INNER JOIN dd02t    ON ( dd02l~tabname = dd02t~tabname )

        WHERE
         tstct~sprsl       EQ ‘S’ AND
          dd02l~as4local    EQ ‘A’
          AND dd02l~as4vers     EQ ‘0000’
          AND dd02l~tabclass    EQ ‘TRANSP’
          AND dd02l~tabclass    IN sottable
          AND dd02t~ddlanguage  EQ ‘S’
          AND tstct~tcode       IN sotcode
          AND tstct~ttext       IN sotext
          AND d010tab~tabname   IN sotname
          AND dd02t~ddtext      IN soddtext.

    (0) 
  4. Deep Bisht

    Dear Faisal Altaf  ,

    I very much like your contribution :

    Get Name of Tables used in T-Code

    But please explain me one thing that why I am unable to get the list of tables/output after entering the

    TCODE  : FMRP_RW_BUDCON  : Budget Consumption Report  .

    It is saying sorry DATA not  found for  Given Criteria .

    So please explain me this issue  . 

    Regards

    Deep

    (0) 
  5. Madhusudhan Mysore Vasudeva

    REPORT zfsl_table_used_tcode NO STANDARD PAGE HEADING.

    TABLES: d010tab, dd02l, tstc, tstct, dd02t.

    ************************************************************************

    *                          Types Defined                               *

    ************************************************************************

    TYPES: BEGIN OF ty_detail,

             tcode   LIKE tstcttcode,

             ttext   LIKE tstctttext,

             tabname LIKE d010tabtabname,

             ddtext  LIKE dd02tddtext,

           END OF ty_detail.

    ************************************************************************

    *            Declaration of Internal Tables & Variables                *

    ************************************************************************

    DATA: it_detail TYPE STANDARD TABLE OF ty_detail WITH HEADER LINE,

           wa_detail LIKE LINE OF it_detail,       cursor_field(30).

    ************************************************************************

    *                      SELECTION SCREEN                                *

    ************************************************************************

    SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text001 NO INTERVALS.

    SELECT-OPTIONS: sotcode  FOR tstcttcode      NO INTERVALS MEMORY ID aaa,

    sotext   FOR tstctttext      NO INTERVALS,

    sotname  FOR d010tabtabname  NO INTERVALS,

    soddtext FOR dd02tddtext     NO INTERVALS.

    SELECTION-SCREEN END OF BLOCK a.

    ************************************************************************

    *                         AT SELECTION-SCREEN                          *

    ************************************************************************

    AT SELECTION-SCREEN.

       IF sotcode[] IS INITIAL AND sotext[] IS INITIAL AND sotname[] IS INITIAL AND soddtext[] IS INITIAL.

         MESSAGE ‘You must select minimum one option’ TYPE ‘E’.

       ENDIF.

    ************************************************************************

    *                        START-OF-SELECTION                            *

    ************************************************************************

    START-OF-SELECTION.

       SELECT tstct~tcode tstct~ttext d010tab~tabname dd02t~ddtext

         INTO CORRESPONDING FIELDS OF TABLE it_detail

         FROM tstc INNER JOIN tstct

         ON ( tstc~tcode = tstct~tcode )

         INNER JOIN d010tab  ON ( tstc~pgmna = d010tab~master )

         INNER JOIN dd02l    ON ( d010tab~tabname = dd02l~tabname )

         INNER JOIN dd02t    ON ( dd02l~tabname = dd02t~tabname )

         WHERE tstct~sprsl       EQ ‘E’

         AND dd02l~as4local    EQ ‘A’

         AND dd02l~as4vers     EQ ‘0000’

         AND dd02l~tabclass    EQ ‘TRANSP’

         AND dd02t~ddlanguage  EQ ‘E’

         AND tstct~tcode       IN sotcode

         AND tstct~ttext       IN sotext

         AND d010tab~tabname   IN sotname

         AND dd02t~ddtext      IN soddtext.

       IF sysubrc EQ 0.

         SORT: it_detail BY tcode tabname.

         WRITE1(149) syuline,             /1(1)   ‘|’,

                 3(20)   ‘Transaction Code’  CENTERED COLOR 1,

                 24(1)   ‘|’,

                 26(36‘Transaction Text’  CENTERED COLOR 1,

                 63(1)   ‘|’,

                 65(20‘Table Name’        CENTERED COLOR 1,

                 86(1)   ‘|’,

                 88(60‘Table Description’ CENTERED COLOR 1,

                 149(1‘|’,             /1(149) syuline.

         LOOP AT it_detail INTO wa_detail.

           WRITE/1(1)   ‘|’,

                    3(20)   wa_detailtcode    HOTSPOT ON,

                    24(1)   ‘|’,

                    26(36wa_detailttext    HOTSPOT ON,

                    63(1)   ‘|’,

                    65(20wa_detailtabname  HOTSPOT ON,

                    86(1)   ‘|’,

                    88(60wa_detailddtext   HOTSPOT ON,

                    149(1‘|’.

           HIDE: wa_detail.

         ENDLOOP.

         WRITE/1(149) syuline.

       ELSE.

         MESSAGE: ‘Sorry, DATA not found for Given Criteria’ TYPE ‘S’.

       ENDIF.

    AT LINE-SELECTION.

       GET CURSOR FIELD cursor_field.

       CASE cursor_field.

         WHEN ‘WA_DETAIL-TCODE’ OR ‘WA_DETAIL-TTEXT’.

           PERFORM show_transaction USING wa_detailtcode.

         WHEN ‘WA_DETAIL-TABNAME’ OR ‘WA_DETAIL-DDTEXT’.

           PERFORM show_table USING wa_detailtabname.

         WHEN OTHERS.

       ENDCASE.

    *&———————————————————————*

    *&      Form  show_table

    *&———————————————————————*

    *       text

    *———————————————————————-*

    *      –>TABLE_NAME text

    *———————————————————————-*

    FORM show_table USING table_name.

       CALL FUNCTION ‘RS_DD_TABL_EDIT’

         EXPORTING

           objname              = table_name

           edit_mode            = ‘S’

         EXCEPTIONS

           object_not_found     = 1

           object_not_specified = 2

           permission_failure   = 3

           not_executed         = 4

           OTHERS               = 5.

       IF sysubrc NE 0.

         MESSAGE ID symsgid TYPE symsgty NUMBER symsgno WITH symsgv1 symsgv2 symsgv3 symsgv4.

       ENDIF.

    ENDFORM.

    “show_table

    *&———————————————————————*

    *&      Form  show_transaction

    *&———————————————————————*

    *       text

    *———————————————————————-*

    *      –>FIELD_VALUE  text

    *———————————————————————-*

    FORM show_transaction USING tcode_in.

       DATA: tcode LIKE tstctcode.   tcode = tcode_in.

       CALL FUNCTION ‘RS_TRANSACTION_SHOW’

         EXPORTING

           objectname       = tcode

           monitor_activate = ‘ ‘

         EXCEPTIONS

           object_not_found = 1

           OTHERS           = 2.

       IF sysubrc NE 0.

         MESSAGE ID symsgid TYPE symsgty NUMBER symsgno

         WITH symsgv1 symsgv2 symsgv3 symsgv4.

       ENDIF.

    ENDFORM.

    “show_transaction

    (0) 

Leave a Reply