Perform Kiuwan analysis in your ABAP Development Life Cycle

This is the fourth installment of our series on Abap analysis. If you are a new reader, check out previous posts on:

1. ABAP Code Quality & Security Vulnerabilities detection
2. Static analysis for ABAP
3. ABAP: continuous analysis with Kiuwan

Chapter 3, ABAP: continuous analysis with Kiuwan, tells us how to run automatically the source code extraction and the Kiuwan analysis, out of SAP environment.

But, if you are a SAP developer, you may want to check your code from your SAP environment, as a new step in your development life cycle.
Either your company has its own development cycle or uses Accelerated SAP, you can benefit from an analysis of Kiuwan to improve your code.


In this post we are going to learn how to run the same steps, inside the SAP server.


Installing the source code extractor

The first task is installing the source code extractor, as we saw on Static analysis for ABAP. As an example, you can use Mass Download, from Dalestech Consulting Ltd.

*To facilitate the process with Kiuwan, we have made some changes in this code, so you can download the program clicking here. The changes are:

  • Rename the extension of the extracted files to .abap.
  • Comment the footers added by massdownload.


Running Kiuwan Local Analyzer from SAP

SAP has different ways to invoke an external program. You can create an ‘External command’ using the SM69 transaction or call directly using the function WS_EXECUTE.

Below there is an example of this second method:


Putting the pieces all together

Finally, we can create a new method, Z_KIUWAN_ANALYSIS, that extracts the source code of our Abap programs and runs Kiuwan Local Analyzer.

The analysis is executed in two steps:

  1. Calls to zdtp_massdownload method to extract some programs to a local directory.
  2. Calls to KIUWAN_LOCAL_ANALYZER method to run the Kiuwan Local Analyzer, passing as source directory the directory where our programs were extracted.


And finally goes to kiuwan

Once the analysis was run, login to Kiuwan and check defects  and create a new action plan to progressively achieve your goals.