In this installment of our IT Partners blog, I will be inviting a good friend of mine Henry Stewart to teach us about using a tool he developed to analyze and perform a WHERE-USED on a RFC in a remote SAP System. Typically, you use the delivered WHERE-USED functionality of the Repository Information System (SE84) inside an SAP instance to discover where the subject object is called or referenced.
But what if the objects calling reference is not in the system that has the RFC? You could log on to every SAP system and do a search, or we can learn from Henry and use his tool.
Here is a brief intro to Henry…..
Henry Stewart has been consulting in the SAP technologies for 8+ years, providing his clients with expert experience in many SAP Modules including SRM, Document Builder, Records Management, FI/CO, SD, MM, PP, RE-FX,HR. Henry has extensive knowledge for implementing SRM in the public sector area customizing and developing unique solutions to meet the needs of his clients. During his free time Henry enjoys spending time with his twin boys, learning new trends in technologies, listening to Audiobooks and watching his alma-mater LSU football. Henry also severed in Louisiana Air National Guard. You can reach him at [email protected]
The ALV Usage to Display Found RFC Locations
Lets pick up in part 2 with a closer look into the ALV Grid and it’s usage from part 1. ALV Programming is an area of ABAP development that allows for presenting the ABAP report in the tabular format with integrated functions as sorting, output in different formats, etc…
There are many good sites for ALV development, on SCN, SAP Help and elsewhere:
ALV stands either for ABAP List Viewer or for SAP List Viewer, and is available in ABAP and Java. In this article we are not presenting ALV development just it’s aspects as it relates to this article. So let’s pick up after we selected the RFC locations.
The result of our SAP Where Used List selection of RFC references and identification of their location in the code is collected in the internal table gt_display:
We would like to present this result to the user in the neat format with a minimum programming. For this reaso, using ALV is a good choice:
We also would like provide the user the capability to drill down – if they double click on the row in the ALV Grid, this should open the specific include in the ABAP editor and point the user to the location of the call.
We use the SAP standard SALV Classes to set-up ALV table:
The local class is used to detect and react to the double-click event:
DATA go_salv_event_handler TYPE REF TO lcl_salv_event_handler.
The standard SAP class CL_SALV_TABLE is used to prepare the table of locations for display and present it to the user for interaction.
The Process starts from:
cl_salv_table=>factory( EXPORTING list_display = abap_false IMPORTING r_salv_table = go_salv_table CHANGING t_table = gt_display ).
And ends with the call:
All ALV set-up goes between this two calls. Example of this set-up could be the code below:
* Set Column names go_salv_columns_table = go_salv_table->get_columns( ). * Get the column in the ALV go_salv_column = go_salv_columns_table->get_column( 'RFC_FM' ). * Change the column header name from the default values go_salv_column->set_long_text( 'External FM' ).
If the user double-clicks on a row in the GRID as shown below
He or she will be taken to the ABAP Editor of the FM B40B_PO_GETDETAIL which is contained in include LBBP_BD_DRIVER_40BU20 to the line 105:
Display Found RFC Location in the Code on Double Click
We use the object go_salv_event_handler to intercept ALV events (e.g. double click) and react to them.
* Handle ALV Grid events. CREATE OBJECT go_salv_event_handler. go_salv_events_table = go_salv_table->get_event( ). SET HANDLER go_salv_event_handler->on_double_click FOR go_salv_events_table.
The local class lcl_salv_event_handler has method on_double_click. It is defined as:
METHODS on_double_click FOR EVENT double_click OF cl_salv_events_table IMPORTING row column.
In other words we provide a connection between the objects:
The Implementation of the method on_double_click has actually one call to FM RS_TOOL_ACCESS. This call passes to this FM name of the include and the position within include.
METHOD on_double_click. FIELD-SYMBOLS <ls_display> TYPE gts_display. TA lv_value TYPE trobj_name. * Read the row READ TABLE gt_display ASSIGNING <ls_display> INDEX row. IF sy-subrc EQ 0. IF <ls_display>-include EQ gc_not_found OR <ls_display>-include EQ gc_rfc_error OR <ls_display>-include IS INITIAL. MESSAGE i001(00) WITH 'Error finding location'. ELSE. CALL FUNCTION 'RS_TOOL_ACCESS' EXPORTING operation = 'SHOW' object_name = <ls_display>-include object_type = 'PROG' position = <ls_display>-line_num EXCEPTIONS not_executed = 1 invalid_object_type = 2 OTHERS = 3. IF sy-subrc NE 0. MESSAGE i001(00) WITH 'Error navigating to code'. ENDIF. ENDIF. ENDIF. ENDMETHOD.
That’s all. The rest is done by SAP.
During the development Henry noticed one peculiarity of how the Function Module “RS_TOOL_ACCESS” points to a specific line in the source code. Any Enhancements placed in the code before the line specified by the parameter POSITION are ignored and the code can be positioned slightly different from the detected position of the RFC. The Enhancements in the code after the RFC do not have such effect.
Program Design – usage of Local Classes
The program z_find_where_rfc_is_called is desaigned as an SAP Report – Executable program.
Major parts of the program were already discussed:
– Selection Screen
– Data retrieval. (RFC locations and lines in the code).
– Data presentation as ALV table.
– Location display on the double click on the row in the ALV table of found locations.
This program uses two different types of processing blocks – Subroutines (or Forms) and Classes.
It is a mixture of the Structured and Object Oriented Programming. Not very far apart chronologically 1960s former and 1970s latter. We can surely replace subroutines by the methods of the class (local or global). The usage of the local class lcl_salv_event_handler is driven by the SAP ALV framework.
The entire code of the program is presented below.
After all the analysis of the program we provided on previous pages probably no actual code is needed. Still to make this article most useful the complete code is below. The user just has to replace the fictional RFC system by the real in his SAP shop. Click the link below.