In my post “SAP project – Application Development Performance Control”, I mentioned we can validate SAP ABAP program performance via static performance check and dynamic performance testing. Static performance check and Dynamic Performance testing complements each other to make sure that program developed has good performance. It is mentioned that we can use SAP code inspector (SAP transaction – SCI) to do static performance check on SAP ABAP program. SAP code inspector can scan through an ABAP program source code line by line to identify common performance pitfalls. In this post, I would share how to run SAP code inspector to do this. This post would cover.
- . Quick start on how to run SAP code inspector to do static code view,
- Details of steps of running SAP code inspector,
- Advanced way of running SAP SCI and
- Further info on SAP SCI, SQLM and SWLT tools.
1. Quick start on how to run SAP code inspector to do static code view on Single Object
1. Run SAP code inspector transaction SCI in any SAP window,
2. Go to “Create” inspection function by clicking “create” inspection button on the initial screen of code inspector,
3. Specify Single ABAP object or Single transport and a list of performance check attributes on the 2nd screen of code inspector,
4. Execute the inspection by clicking “execution button” on the 2nd screen,
5. Review the inspection results.
2. Details of steps of running SAP code inspector
2.1 Run SAP code inspector transaction SCI.
To start SAP code inspector, I typed in SAP transaction code “/nSCI” in the command window of my SAP screen (as showed in following screen) and hit “return” key to start the SCI transaction.
Figure 1 Start SAP inspector
2.2 Go to “Create” inspection function
Following the hitting “return” key in 2.1 step, initial screen of SAP SCI appeared.
Figure 2 SAP Code Inspector Initial screen
I clicked “create” button in Figure 2, then following screen appeared.
Figure 3 SAP code inspector – specification screen
Assuming that this was the very first time I run SCI in the system, I do not have any “check variant” created so I need to specify my check options manually by checking related boxes in Figure 3.
2.3 Specify Single ABAP object or Single transport and a list of performance check attributes
I need to do static performance check on an ABAP program. So I entered following data and unchecked “security check” options except “Performance check” in Figure 3 and I expanded “Performance checks” to show a list of performance items checked as Figure 4.
Figure 4 SAP code inspector – check on single ABAP object
2.4 Execute the check
I was glad with my input, then I clicked “execution” button( red circled in Figure 4) to let the code inspector to do static performance check.
2.5 Review result of SAP code inspection
Upon completion of SCI execution in above step, SAP Code inspector displayed a result screen showed as in Figure 5.
Figure 5 SAP code inspector – checking result
SAP classifies the checking result into 3 classes – error, warning and information. SAP provides several features to help you navigate through the result screen – this is helpful many objects are collectively checked with many errors and warning.
In figure 5, static performance check on the code find no error but 4 warning. To see details, I clicked “result list” button and I got following screen (Figure 6).
Figure 6 SAP code inspector – result list
I double clicked the program line in Figure 6 to see the corresponding ABAP source line related to “Nested loops”
Figure 7 SAP code inspector – Detection of Nested Loop
With above information, I can discuss with ABAP developer on the concern and reach the decision on whether this should be fixed or exempted before the change can be moved to production.
So far, what I showed is a quick start to use SAP code inspector to do static performance check on a single ABAP object and review the result. This is good enough for one time check on single object (ABAP or transport request). But there are several limitations/disadvantages to run SCI this way:
- SCI result would not be saved by SAP. You have to download the SCI result manually before you quite from SAP SCI transaction if you would like to keep the result.
- You can check only single transport or single ABAP object during each execution,
- You have to enter object name each time you need to check the ABAP object and
- You have to specify the list of checks every time manually when you execute the SCI. You can use existing check variant but you have no control on the check variant which you are not responsible for.
If I would like to refer to the static performance check result in the SAP SCI in the future, or I need another person to review the check result via SAP SCI, or I need to check a lot of objects, or if I always do the same set of checks and hate to click those options one by one every time, or is there any option to execute the check in background to avoid timeout or make execution faster when I have a lots of objects to check? Can SAP SCI allow me to do so? Yes, I called it advanced way of running SAP SCI.
3. Advanced way of running SAP SCI
SAP SCI provides several ways for you to define an object set which contains the ABAP objects to be checked. SAP SCI allows you to define a check variant to contain a list of check attribute you like to have so you can use it for similar check again and again. SAP SCI can save the inspection result if you give it a name during execution. SAP SCI provides “background” options to avoid timeout and “parallel execution” option to speed up the execution.
3.1 Define a check variant for regular checks you do normally
Most of time, I use SCI to do performance check and I normally focus on reading table without index, nested-loop, by-passing SAP buffer etc. I would like to create a SAP SCI check variant to contain the list of performance checks I need so I do not enter them every time in the future. 3 steps:
- Name your check variant,
- Select a list of checks you need and
- Save your variant
I named my variant “ERIC_PERF_DB” (free text for all names in SAP SCI), then I clicked “create” button highlighted in Figure 8.
Figure 8 SAP SCI – name check variant
Following clicking on the “create” button, following screen showed up with a list of checks which I can choose from.
Figure 9 SAP SCI – a list of available check
If you would like to understand more about each checking category, you can click the Info button, SAP would pop up a screen to tell you what the check category is for.
Since I am interested in performance only, I checked following choices by clicking the white square “boxes”.
Figure 10 SAP SCI – choose check category and associated check attribute
I saved the “ERIC_PERF_DB” variant by clicking the “Save” button. You can see that my variant is to focus on SQL statements and targeted for programs which mainly spends runtime on database access. For such programs, it makes no sense for SAP SCI to check “low performance operations on internal tables” etc…
You can display, change, copy and delete an existing variant by clicking correspond buttons in the “check variant” section of SAP SCI initial screen.
3.2 Define a object set for SAP SCI check
If you would like to check a lot of objects repeatedly, it is tedious to enter each object every time you run SAP SCI transaction. If there are many objects in a package or in a function group etc. it is tedious to list each object in a package or a function group etc. SAP SCI provides several ways to allow you to specify a set of objects to be checked together by SAP SCI transaction. Following are steps to define the object set.
- 1. Name your object set,
- Enter your object sets directly or adopt objects from existing object sets created by you or other people earlier you and
- Save your object set.
I named my variant “ERIC _DB_EXTENSIVE_REPORTS”, then I clicked “create” button highlighted in Figure 11.
Figure 11 SAP SCI – name Object set
Following clicking on the “create” button, following screen (Figure 12) showed up with several tabs to give you a lot of options to allow you efficiently to specify objects.
Figure 12 SAP SCI – options for specifying check objects
Here, I am only going to check several programs. So I uncheck all options first, then I checked “Program” Options and click “arrow” button highlighted in Figure 12 to enter a list of objects.
Figure 13 SAP SCI – Sample ABAP objects
Figure 13 is a list of sample objects I specified, then click “continue” button, and SAP returned me to the Object set screen below.
Figure 14 SAP SCI – Objects specified
At last, I clicked “Save” button circled in red color in above Figure 14 to save my object set “ERIC _DB_EXTENSIVE_REPORTS”.
So far, I have defined check variant “ERIC_PERF_DB” and Object set ““ERIC _DB_EXTENSIVE_REPORTS” using SAP code inspector. It is time to run SAP SCI to do the needed checks specified in check variant against those objects through the defined object set.
3.3 Create SAP SCI inspection with a name for future reference
If you enter a “name” for SCI inspection, the SCI static checking result would be saved in SAP database upon completion so this can be reviewed using the name via SCI in the future. When you have a big object set and SAP SCI returns a long list of result. You might need more than one person to review the SCI result as well. So naming an inspection has at least following benefits
- Save the result for the future reference,
- Separate SCI execution and result reviewing,
- Allow several people to work on the long list of SAP inspection result.
I named my SCI static check or Inspection as “ERIC_CHECK_DB_EXPENSIVE_REP”, then I click create button highlighted in Figure 15
Figure 15 SAP SCI – advanced usage ‘name the inspection’
Following the click, I got following Inspection screen where I used option “object set” and entered the set I created earlier “ERIC_DB_EXTENSIVE_REPORTS” and Selected “ERIC_PERF_DB” check variant as showed in Figure 16. You can use pull-down button to choose your options from a list.
Figure 16 SAP SCI – using object set and check variant
With specified “object set” and designated “check variant”, I click “execution” button circled in red in Figure 16 to kick off the inspection. After SAP code inspector finished checking/inspection, I got following result screen.
Figure 17 SAP SCI – result screen for named inspection
In Figure 17, you can click “button” circled in red color to review the inspection result. You can filter the result and sort result as well via buttons showed in Figure 17. The green button before the name of inspection indicates that SCI is executed successfully for the inspection.
3.4 Execute SAP SCI in background or using parallel solution
When there is a lot of objects to be inspected, the execution can be long. SAP SCI provides “execution options” to allow you to execute it online or execute it in background using parallel processing.
Figure 18 SAP SCI – execution options
I clicked the button circled in red in Figure 18. I need to run the inspection in background job and via parallel solution controlled by the server group defined by RZ12, so I specified input based on my environment as showed in Figure 19.
Figure 19 SAP SCI – selected execution option
Number in red in Figure 19 indicates sequence of operations in executing the inspection via options. Figure 20 shows the job name SAP SCI created in this case. The job name convention = CODEINSP_ + Inspection name + _Version.
Figure 20 SAP SCI – background job for inspection
Here, Server group and parallel processing is provided as an option to do static performance check. If you are interested, you can refer to my post on how to create SAP server group via RZ12 and refer to my post on general introduction on SAP parallel processing.
4. Further info on SCI, SQLM and SWLT
You properly noticed that static performance check on ABAP code is just one of checks offered by SAP code inspector. You can do other checks in the same fashion I mentioned here for performance check. SAP code inspector is focusing coding technique not logic. So it would not tell you logic/design issue – like you execute a operation at sale order line item level while the operation only need to execute once for one sale order.
ABAP code review for static check can be done manually but manual check has many disadvantages like cost, inconsistent result and painful.
SAP code inspector is integrated with SAP object creation and editor tool like SE11 – data dictionary, SE38 (ABAP program editor), SE37, SE24 (class builder) and etc. As a developer, you can call SAP code inspector in the tool to do static check directly. Such check is done via “Default” check variant defined by the developer. For example, SAP developer can invoke the code inspector to do static check from the same SE38 screen where code changes are made.
SAP code inspector is doing a static check based on a predefined set of criteria. It has no information on actual usage of ABAP code in production environment or how big a table is… Due to business changes, a code which is executed frequently might be obsoleted over time. You do not spend effort on an obsoleted codes due to code inspector complaining … for that purpose, SAP has introduced another tool SWLT to integrated code inspector result with SQL usage information from SQL monitor which might help drive priority of fixes some times. In my understanding, SAP SWLT and SAP SQLM is targeted for Hana migration and Hana environment. I would cover SAP tool SWLT and SQL monitor in the future.