Monday, March 22, 2010

Finding functions in SAP

In SAP world there is usually more than one way to do something. This is true in functional processes where several transactions can perform the same action. It is also true in the development area where one can find in the SAP database several functions that perform the same (or almost the same) action.

When "shopping" for a function I usually check the number of times the function is used in the standard code. Since this information is available in a table it is easy to build a list the top used functions (in the picture a word map of the top used APO functions without the /SAPAPO/ prefix for easier readability).

Bellow is a minimal report to query the functions and get the usage counter. I think such report is quite useful for day to day work. Consider the following sample case where I want to find a function to display a pop-up message. Using this report I do a query by *POPUP*.

It will display __ entries sorted by the number of times that function is used. As there are many possible functions it is nice to know the ones that are more often used, since those are more likely to work better.

The report code:

report z_top_used_functions.

tables cross.
gt_objs type table of ztopusedfunctions.

selection-screen begin of block 0 with frame title text-002.
s_name for cross-name.
selection-screen end of block 0.

selection-screen begin of block 1 with frame title text-001.
p_type like cross-type default 'F',
p_max type tbmaxsel default 200.
selection-screen end of block 1.

clear gt_objs.
refresh gt_objs.

select name count(*) as counter
from cross
up to p_max rows
into table gt_objs
where type = p_type
and name in s_name
group by name
order by counter descending.

call function 'REUSE_ALV_GRID_DISPLAY'
i_structure_name = 'ZTOPUSEDFUNCTIONS'
t_outtab = gt_objs.

The ztopusedfunctions structure is defined as follows.

Happy coding.

Labels: ,


Blogger Bruce Tjosvold said...

What is the structure you are using, ZTOPUSEDFUNCTIONS?


12:43 AM  
Blogger pvl said...

Hi Bruce, you can find the definition in the screenshot in end of the post. Regards, Pedro.

10:41 AM  
Anonymous Anonymous said...


9:01 AM  
Anonymous Anonymous said...

Nice Idea Pedro!
Tcodesearch also uses similar concept to list commonly used FMs.

7:40 PM  

Post a Comment

<< Home