Understanding the ABAP Program Logic With Profile Data Analyzer – ME23N
In the previous blog posts, we have introduced profile data analyzer to analyze the profiling data (e.g. the ABAP trace, and the Java *.prf file), and how to use it to understand the program logic to support the performance tuning or other troubleshooting tasks using a BASIS T-Code SU01.
Blog Post Series for profile data analyzer The Example Used Publish Date Changes for Profile Data Analyzer The summary for all the changes and resources 2021/03/23 Analyze ABAP Performance Traces with the Profile Data Analyzer SM21 Trace 2020/04/01 Understanding the ABAP Program Logic With Profile Data Analyzer for Performance Optimization and Other Tasks SU01 Trace 2020/05/06
In this blog post, I will use a real-world application T-Code: ME23N (Display Purchase Order) to further demonstrate how the profile data analyzer could be used to understand the program logic and benefit the performance tuning and other tasks. (The system environment is SAP ERP 6.0 EHP8.)
The ME23N example in this blog post
Suppose we do not have any knowledge about ME23N’s code and let’s use the profile data analyzer to find out the answers to the following questions of ME23N.
- What is the method to open a Purchase Order (PO)?
- What is the database table for PO header data?
- What is the database table for PO items?
- Is there any BADI that could be used in ME23N?
Here is the main flame graph generated by the profile data analyzer for ME23N.
To get the above flame graph, please follow the steps below:
- Set the SAT/SE30 trace variant to “no aggregation” or “aggregated by call stack” following KBA 2881237.
- Go to SAT or SE30 to trace T-Code ME23N.
- In ME23N, click “Other Purchase Order” to open a Purchase Order (PO).
- Download the ABAP trace following KBA 2881237
- Analyze the trace by profile data analyzer as per KBA 2879724.
If you have an environment to run T-Code ME23N, I suggest taking a ME23N ABAP trace and then practice the trace following the steps in this blog post. It is also OK if you do not have a ME23N environment because you could always follow the idea with the screenshots in this blog post.
What is the method to open a Purchase Order (PO)?
Suppose we do not have any knowledge about ME23N, then we usually need to guess or try some points to start.
- The “OPEN” is a good keyword because we want to find out the method to open a PO.
- The “OTHER” is another good keyword because the button name is “Other Purchase Order”.
Now let’s search “OPEN|OTHER” in the flame graph (following KBA 2946431), and then we could get the following interesting methods like the following screenshot.
- LCL_APPLICATION.OTHER_DOCUMENT() – call position=SAPLMEGUI:77485
- LCL_TRANSACTION_PO.OPEN() – call position=SAPLMEGUI:67329
We could find out the exact call position following KBA 2916386. Then we could set a breakpoint to “LCL_TRANSACTION_PO.OPEN” and confirm that “LCL_APPLICATION.OTHER_DOCUMENT” and “LCL_TRANSACTION_PO.OPEN” are just the methods to open a PO. Furthermore, we could also confirm that “L_NEW_DOCS-DOC_KEY” is just the PO number we want to OPEN like the following screenshot. (BTW, if you go through the flame graph deeper, you might find “LESEN_BELEG” for PO reading in a detailed level. This form will be discussed later.)
What is the database table for PO header data?
Now let’s move to the next task to find out the header table for PO.
Let’s zoom to “LCL_TRANSACTION_PO.OPEN” to check its details, and then we could found the FORM “LESEN_BELEG” which is interesting to read a PO.
While debugging “LESEN_BELEG”, we could find out that “EKKO-EBELN” is the PO number. One tip here is that the “EKKO” is the table name, and the “EBELN” is the column name.
Now we could confirm in SE11 that EKKO is just the table for PO header data.
The header table EKKO could also be fingered out by checking the code “LESEN_BELEG” no matter in the flame graph or the source code like the following screenshots.
We can also find that the flame graph is easier than reading the code in SAPGUI when we want to get an overall picture, because both function module ME_EKKO_SINGLE_READ and the table name EKKO are shown on the call stacks on the flame graph.
What is the database table for PO items?
As shown in the previous part, FM “ME_EKKO_SINGLE_READ” for header table EKKO is called by FORM “LESEN_BELEG”. So we should check the methods near FORM “LESEN_BELEG” to find out the items table firstly, because the codes accessing the header table and the item table are usually near each other.
Following this idea, we could find out “LESEN_EKPO_IN_POT” which is responsible to read the items from the item table “EKPO” like the following screenshot.
Here is the information in SE11 for the item table EKPO.
Here is the information in the debugger where the PO items are read.
Another interesting point in the above screenshot is the FORM “POT_AUFBAUEN” which is called within the “SELECT – ENDSELECT” section (e.g. there might be several PO items). This relationship could also be confirmed on the flame graph like the following screenshot.
Is there any BADI that could be used in ME23N?
In my example, the trace is taken on an IDES system, so there are already some enhancements in the system. We could find them out by searching “BADI” or finding the pink frames for the custom code (KBA 2946441) in the flame graph (or searching it in SAP JVM Profiler if the BADI is too short following KBA 2891307).
Here is the BADI “ZCL_IM_EHS_SVT_PROCESS_PO” implemented “IF_EX_ME_PROCESS_PO_CUST” in the flame graph.
Here are the BADI details for “ZCL_IM_EHS_SVT_PROCESS_PO” and “IF_EX_ME_PROCESS_PO_CUST”.
Additional Information & Summary
The information in this blog post does not cover all the details of ME23N. In real cases, the reason for a ME23N issue might be related to some other programs or tables which are not mentioned in this blog post, and such situations should be analyzed case by case. For example, the following tables are also important for a PO and ME23N. (BTW, both EKKN and EKET use “EBELN – Purchasing Document Number” and “EBELP – Item Number of Purchasing Document” as a part of the key. The call stacks and the context of these two tables could also be verified on the flame graph.)
- EKKN – Account Assignment in Purchasing Document
- EKET – Scheduling Agreement Schedule Lines
Now let’s look back at the following questions and answers we discussed in this blog post. We could see that the profile data analyzer could help us to understand the ABAP program which will benefit the performance tuning and other tasks.
The question How profile data analyzer could help us? What is the method or function module to open a Purchase Order (PO)? Understanding the ABAP program logic. What is the database table to save the PO header data? Understanding the underlying data structure and database tables. What is the database table to save the PO items? Understanding the underlying data structure and database tables. Is there any BADI that could be used in ME23N? Understanding how the program could be extended.
At last, please feel free to reach me or write a comment here if there is any feedback about the profile data analyzer. Thank you very much.