Before you start:
Please read the “Before you start” section in this blog first:
We’ll use the “Current Mode” scenario and the same tracing options as described in the above mentioned blog. Furthermore we will use the particular units option described here:
ST12 – Tracing particular units
Looking at the main screens (see figure 1) of SE30 / SAT and ST12 one can see that there is no direct option for tracing function modules in ST12.
Figure 1 – Tracing function modules
But since we can execute a function module in SE37 with the test/execute option we will setup a trace for transaction SE37 in ST12. The goal is to trace ONLY the execution of the function module but not the start of SE37 or the other steps that we might execute in SE37. This blog will show how to trace such a particular unit (e.g. the test/execute in SE37 but not the whole SE37).
Executing the trace for particular units
All we have to do is to mark the part we want to trace while we execute SE37. The prerequisite is that you switch on the “Particular Units” option in ST12 as shown in nr. 1 in figure 1 before you execute the trace (nr. 2 in figure 1). Note: this option is only available in the “Current Mode” Scenario.
If you look at figure 2 which shows the steps we execute in SE37 in order to do a test execution of a function module in SE37 you can see that there are some steps that we don’t want to trace:
We don’t want to trace the whole execution (dashed black arrow) between T1 and T2 but only the execution of the function module (solid red arrow) between T1a and T1b. Note: As you can see in figure 2 the ST05 trace (dashed green arrow) records the whole execution of the transaction but not only particular units of it.
Figure 2: Executing SE37 test/execute with current mode particular units
So during the execution we have to mark which parts of the execution should be traced (ABAP trace):
Figure 3: SE37
After you start the trace (nr. 2 in figure 1) SE37 (or the transaction /program you entered in the corresponding transaction / program field in ST12 in the main screen) will show up. Since we switched on the “Particular Units” nothing is traced so far. Now we enter the function module that should be traced and click the test / execute button (nr 1 in figure 3 or F8) in SE37 again, nothing will be recorded in the trace. Now you can see the interface of the function module. After filling in the parameters the next step would be the execution of the function module (nr. 4 in figure 3). BEFORE we execute we have to set the marker that we want to trace starting from here. For doing so we enter “/ron” in the transaction code field (nr. 2 in figure 3) and press enter. After that you can see the “Runtime analysis enabled” message in the bottom of the screen (nr. 3 in figure 3). After that we execute the function module. The next screen shows the result of the function module. We have to set the second marker now that indicates we want to stop trace recording so that nothing else is traced from this point on. We enter “/roff” in the transaction code field (nr. 5 in figure 3). We get the message “Runtime analysis disabled” at the bottom of the screen (nr. 6 in figure 3). After going back (which is not traced) the trace is imported in the database as described in the above mentioned blog.
Function modules with complex interfaces
We used a function module with a rather simple interface. If you have a function module with a more complex interface (tables or deep structures) you could use the new debugger to generate the test data for SE37 automatically.
All you have to do is to step in the function module in the new debugger e.g. by setting a break point in the first line of the function module (nr. 1 in figure 4). On the “Variable Fast Display” tool choose the “services icon (nr. 2 in figure 4). On the following popup double-click “Save Parameters as Test Data (SE37). On the next popup (nr. 4 in figure 4) you have to fill in a title which allows you to recognize the test data again in the SE37 test data directory and confirm this dialog with the green tick.
Figure 4: SE37 – storing interface parameters in the test data directory
In order to execute the function module with the interface test data you have just saved you have to do the following steps:
- 1.) Start transaction SE37
- 2.) Click on “Test data directory” in the icon menu (nr. 5 in figure 4)
- 3.) Choose the test data you have just saved and double-click
- 4.) Now you are ready to execute the function with the generated test data and can use “/ron” as described above to only measure the execution of the function module.
This blog demonstrated how to trace a function module with the “Particular Units” option which is very useful if you want to trace a specific part of a program.
More information on ST12 can be found here:
ST12 WIKI and Blogs: