Skip to Content
Technical Articles
Author's profile photo Stefan Schnell

Tip: ClassViewer for older SAP Systems

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.

ClassViewer.jpg

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.

Assigned Tags

      3 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hello Stefan,

      for older SAP systems you can just enter in SE24  function code SHOW_CLIF. This will start a report where you can download the complete class or seperate includes.

      Best regards, Tapio

      Author's profile photo Stefan Schnell
      Stefan Schnell
      Blog Post Author

      Hello Tapio,

       

      thanks for sharing this information. It seems that SHOW_CLIF is only available on older systems, I can’t find it in a current release.

       

      Cheers

      Stefan

      Author's profile photo Former Member
      Former Member

      Hello Stefan,

      yes, this is correct. But for actual releases you have already Source-code based editor view. 😉

      Best regards, Tapio