Rarely posted in the pastCodeToday, I am quite satisfied with this writing. I will post it for you to see.
Code
*&---------------------------------------------------------------------*
*& Report zclasstree
*&
*&---------------------------------------------------------------------*
*& Author: QiangSheng@hotmail.com
*& Create: 2009 - 06 - 09
*&
*& This program can find the inheritance tree of Class ,
*& From it ' S root class, to all the sub-class of this root.
*&
*& There Is A little bug In This Report. Because of the Function - Code
*& Machism In SAP list tree function modules, when you press
*& " Expand " Button on left of a node, it will Return The Double - Click
*& Function - Code, and you will be navigate to " Class Builder "
*& First, then when come back, the node expanded.
*& If you Don ' T want this, use the expand button on application bar
*& Instead.
*&---------------------------------------------------------------------*
Report zclasstree.
Tables: seometarel, seoclass.
parameters: pclsname like seometarel - clsname obligatory.
selection - screen comment / 1 ( 80 ) comm1.
selection - screen comment / 1 ( 80 ) comm2.
*Type-Pools: fiber, Stree.
Data: t_node type snodetext.
Data: node_tab like t_node occurs0With header line.
Data: fclsname like seometarel-Clsname.
at selection - screen output.
comm1 = ' input the class name, I will create it '' S inheritance tree for you. ' (c01 ).
comm2 = ' In the navigate tree, double click a node to go to the class builder. ' (c01 ).
At Selection-Screen.
Select single*From seoclass where clsname=Pclsname.
If SY-Subrc ne0.
Message'Class not exist!'(M01) Type'E'.
Endif.
Start- Of - Selection.
Fclsname = Pclsname.
* Search For The Root Class .
Do.
Select single * From seometarel where clsname = Fclsname and reltype = 2 .
If SY - Subrc EQ 0 .
Fclsname = Seometarel - Refclsname.
Else.
Exit.
Endif.
Enddo.
* Search For All sub - Class And create the list tree.
Perform search_subclass using fclsname ' 01 ' .
If lines (node_tab) eq 1 .
Message ' Class is standalone. ' (M02) Type ' S ' .
Endif.
*Create the list tree.
Call Function'Rs_tree_construct'
Tables
Nodetab=Node_tab.
Call Function ' Rs_tree_list_display '
Exporting
Callback_program = Sy - Repid
Callback_user_command = ' User_command '
Status = ' Standard '
Use_control = ' L ' . " F: display as control, L: display as list.
*&---------------------------------------------------------------------*
*& Form search_subclass
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
* --> P_fclsname text
*----------------------------------------------------------------------*
Form search_subclass using uclsname ulevel.
Data: clevel type N Length 2 .
Node_tab - Type = ' P ' .
Node_tab - Name = Uclsname.
Node_tab - Tlevel = Ulevel.
Node_tab - Nlength = ' 40 ' .
If uclsname EQ pclsname.
Node_tab - Color = 6 .
Else.
Node_tab - Color = 4 .
Endif.
Select single descript from seoclasstx into node_tab - Text where clsname = Uclsname and Langu = Sy - Langu.
* Node_tab - Text = '' .
Node_tab - Tlength = ' 70 ' .
Node_tab - Tcolor = 3 .
Append node_tab.
Select*From seometarel where refclsname=Uclsname.
Clevel=Ulevel+ 1.
Perform search_subclass using seometarel - Clsname clevel.
Endselect.
Endform. " Search_subclass
*&---------------------------------------------------------------------*
*& Form user_command
*&---------------------------------------------------------------------*
* Text
*----------------------------------------------------------------------*
* --> Node text
* --> Command text
* --> Exit text
* --> List_refresh text
*----------------------------------------------------------------------*
Form user_command tables node Structure seucomm
Using command
Changing exit
List_refresh.
If command EQ ' Trpi ' .
Set parameter ID ' Class ' Field Node - Name.
Call transaction ' Se24 ' And skip first screen.
Endif.
Endform. " User_command