Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to build a subroutine calling tree ?

Former Member
0 Kudos

Hi,

I'd like to build a calling tree for a given program (or function module anyway).

Something that tells me wich forms or function modules are called in my program.

Something that gives me a hierarchy :

Program1

-


> FM 1

-


> Form 1

-


> Form 2

-


> FM 2

-


> Form 3

-


> Form 4

-


> Form 5

And so on...

Does such a tool exist ?

Thank you for your help.

Q. Saderne

1 ACCEPTED SOLUTION

Former Member
0 Kudos

yes, these are function modules which used to display tree

CALL FUNCTION 'RS_TREE_CONSTRUCT'
       TABLES
            nodetab            = t_node
       EXCEPTIONS
            tree_failure       = 1
            id_not_found       = 2
            wrong_relationship = 3
            OTHERS             = 4.

  IF sy-subrc <> 0.
    sy-msgty = 'S'.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    STOP.
  ENDIF.

  CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
       EXPORTING
            callback_program      = 'YH1063_TREETEST'
            callback_user_command = 'USER_COMMAND'
            callback_top_of_page  = 'TOP_OF_PAGE'
            callback_gui_status   = 'TREE'.

where the sturcture of t_node will be like :

fs_node-name  = 'Programs.   << label name
  fs_node-nlength = 50.
  fs_node-color = 1.
  fs_node-tlevel = 1.              << Level depth
  APPEND fs_node TO t_node.

and to know about function modules, forms, tables, symbols etc, one must have the knowledge of SCAN statement

t_node is the table which will contain your actual data.

11 REPLIES 11

Former Member
0 Kudos

yes, these are function modules which used to display tree

CALL FUNCTION 'RS_TREE_CONSTRUCT'
       TABLES
            nodetab            = t_node
       EXCEPTIONS
            tree_failure       = 1
            id_not_found       = 2
            wrong_relationship = 3
            OTHERS             = 4.

  IF sy-subrc <> 0.
    sy-msgty = 'S'.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    STOP.
  ENDIF.

  CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
       EXPORTING
            callback_program      = 'YH1063_TREETEST'
            callback_user_command = 'USER_COMMAND'
            callback_top_of_page  = 'TOP_OF_PAGE'
            callback_gui_status   = 'TREE'.

where the sturcture of t_node will be like :

fs_node-name  = 'Programs.   << label name
  fs_node-nlength = 50.
  fs_node-color = 1.
  fs_node-tlevel = 1.              << Level depth
  APPEND fs_node TO t_node.

and to know about function modules, forms, tables, symbols etc, one must have the knowledge of SCAN statement

t_node is the table which will contain your actual data.

0 Kudos

Hi,

Thank you for your answer.

These function modules seems to be used to build a tree.

But what I'm looking at is a tool to build automatically a calling tree.

I mean a tool to which I give the program name, and that answers me the call tree.

Do you know such a tool ?

Thanks anyway.

Q. Saderne

matt
Active Contributor
0 Kudos

I'm not aware of exactly such a program in standard SAP. You could write one using the SCAN keyword, which tokenises ABAP code.

Alternatively, you could use the code inspector, which tells you which components of a program get hit as it is run.

How would you want to handle:

IF condition.
  PERFORM myform.
ENDIF.

Former Member
0 Kudos

I did not find any tool, so I started to build it...

0 Kudos

Being curious here: but what are you going to use it for?

0 Kudos

I work on a large an old project.

This will let us analyze and get a better view of some obscure reports...

And we'd like too to build a reverse tree. That is to say as where-used list, but with a hierarchy. It would help in finding the impacts of some devs.

0 Kudos

Mmm. I understand. But how will you go about recursive form calls? How will you deal with dynamic calls of forms and/or function modules?

It sounds like a good plan, but i doubt it will be helpful as a tool for analysis. As i see it (admittingly, i don't know what you are planning to program in it) you will only see the calls of functions, forms, modules and nothing more. It would only serve as an overview tool.

0 Kudos

That's why I was looking for an existing tool, because it's a bit tricky to write...

So at the moment an overview tool is better than nothing

But if you know more about the subject, I'd be glad to learn

0 Kudos

I don't know the release you work with, but on my system (ECC6) there is the code inspector.

I haven't tried it out with a serious program, but it does some analysis on a program.

0 Kudos

I know Code Inspector, but certainly not completely.

Have some doc about it ?

How would you use it to get a hierarchy of the routines of the program ?

0 Kudos

Haven't looked at it myself (in a serious way, only wrote a little trash program and ran CI on it). So on my to do list: check out Code Inspector.