Application Development 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: 
stefan_schnell
Active Contributor
If you work with ADT you have, in comparison to the SE80, a total other view to the source of a class. In the SE80 you have different tabs and buttons, and with one or more mouse clicks you navigate to the source part you want to see. But often it is helpful to see the complete source code of a class in one view. Therefore I developed a small report which do that. It is for older SAP systems which don't have the possibility to use the ADT. So it could be a little bit easier to handle extensive source code classes, e.g. for searching.



Here the source code:
"-Begin-----------------------------------------------------------------
  Program Z_CLASSVIEWER.

    "-Begin Class-------------------------------------------------------
      Class Z_CL_VIEWER Definition Inheriting From CL_GUI_CONTROL
        Final Create Public.
        Public Section.
          Type-Pools CNTL.
          Methods Constructor Importing Parent Type
            Ref To CL_GUI_CONTAINER.
          Methods Dispatch Redefinition.
          Methods SetDataSource Importing ClassName Type String.
      EndClass.

      Class Z_CL_VIEWER Implementation.

        Method Constructor.
          Call Method Super->constructor
            Exporting
              CLSID = 'SAPGUI.TextEditCtrl'
              PARENT = Parent
              LIFETIME = 2
            Exceptions
              Others = 1.
        EndMethod.

        Method Dispatch.
          Call Method CL_GUI_CFW=>Flush.
        EndMethod.

        Method SetDataSource.

          "-Variables---------------------------------------------------
            Data l_Tab_RepObj Type Standard Table Of TADIR.
            Data l_Str_RepObj Type TADIR.
            Data l_Pattern Type String Value ''.
            Data l_Tab_RepSrc Type Standard Table Of REPOSRC.
            Data l_Str_RepSrc Type REPOSRC.
            Data l_Tab_Rep Type Standard Table Of String.
            Data l_Str_Rep Type String Value ''.
            Data l_Str_Source Type String Value ''.
            Data l_LineCount Type i Value 0.

          "-Main--------------------------------------------------------
            Select * From TADIR Into Table l_Tab_RepObj
              Where OBJ_NAME = ClassName And OBJECT = 'CLAS'.
            If sy-subrc = 0.
              Loop At l_Tab_RepObj Into l_Str_RepObj.
                Concatenate l_Str_RepObj-OBJ_NAME '%' Into l_Pattern.
                Select * From REPOSRC Into Table l_Tab_RepSrc
                  Where PROGNAME Like l_Pattern And R3STATE = 'A'.
                If sy-subrc = 0.
                  Loop At l_Tab_RepSrc Into l_Str_RepSrc.
                    Read Report l_Str_RepSrc-PROGNAME Into l_Tab_Rep.
                    If sy-subrc = 0.
                      Concatenate l_Str_Source cl_abap_char_utilities=>cr_lf
                        '">>>' l_Str_RepSrc-PROGNAME '<<cr_lf Into l_Str_Source.
                      Loop At l_Tab_Rep Into l_Str_Rep.
                        Concatenate l_Str_Source l_Str_Rep
                          cl_abap_char_utilities=>cr_lf Into l_Str_Source.
                      EndLoop.
                    EndIf.
                  EndLoop.
                EndIf.
              EndLoop.
            EndIf.

            Call Method Set_Property
              Exporting
                PROPERTY = 'Text'
                VALUE = l_Str_Source.

            Call Method Set_Property
              Exporting
                PROPERTY = 'UseFixedFont'
                VALUE = 1.

            Call Method CL_GUI_CFW=>FLUSH.
        EndMethod.

      EndClass.
    "-End Class---------------------------------------------------------

    "-Variables---------------------------------------------------------
      Data Ref_Dock Type Ref To CL_GUI_DOCKING_CONTAINER.
      Data Ref_Viewer Type Ref To Z_CL_VIEWER.
      Data NameOfClass Type String.

    "-GUI---------------------------------------------------------------
      Selection-Screen Begin Of Block Viewer.
        Parameters clName(40).
      Selection-Screen End Of Block Viewer.

    "-Initialization----------------------------------------------------
      Initialization.
        clName = 'CL_BSP_FLIGHT_DEMO'.

    "-Main--------------------------------------------------------------
      At Selection-Screen.

        NameOfClass = clName.

        If Ref_Dock Is Initial.

          Create Object Ref_Dock
            Exporting
              REPID = sy-repid
              DYNNR = sy-dynnr
              SIDE = CL_GUI_DOCKING_CONTAINER=>dock_at_bottom
              RATIO = 85
            Exceptions
              Others = 1.

          Create Object Ref_Viewer
            Exporting
              PARENT = Ref_Dock
            Exceptions
              Others = 1.

        EndIf.

        Call Method Ref_Viewer->setdatasource
          Exporting
            ClassName = NameOfClass.

        Call Screen 1000.

"-End-------------------------------------------------------------------

A class is stored in different entries with the following suffix:

  • ccdef = Local Types

  • ccimp = Local Implementation

  • ccmac = Macros

  • ci = Definition of Private Components

  • cm* = Methods

  • co = Definition of Protected Components

  • cp = Class Pool

  • cu = Definition of Public Components


Enjoy it.
3 Comments