Static analysis for ABAP

A few days ago, Luis Doreste wrote about ABAP Code Quality and the benefits you can get using KIUWAN. Continuing our series on ABAP, we get into detail and give an overview to the process required to perform quality analysis of ABAP code using KIUWAN.

 

If you are newbie to SAP, you will encounter a very different development environment compared to Java or C. Development environment and source code of ABAP programs reside on the same SAP.

Therefore, to analyze the source code with KIUWAN, the first thing we have to do is extract the code from SAP to text files, as we are used to do for other languages.

Normally, you will have people, as SAP specialist, who will help with this task, but in this post we will give a step by step guide of what to do, to serve as an example.

 

Going into SAP

First of all, you need a SAP environment where is the ABAP code you want to analyze. If you have not access to a development or test environment, you can download an evaluation version clicking here.

Installation takes a very long time (more than 16 hours in my laptop), so plan in advance. Once you have installed the SAP NetWeaver 7.01 ABAP Application Server and the SAP GUI for Windows, you can log in the system with the default user: BCUSER, and password: minisap.
1
Installation takes a very long time (more than 16 hours in my laptop), so plan in advance. Once you have installed the SAP NetWeaver 7.01 ABAP Application Server and the SAP GUI for Windows, you can log in the system with the default user: BCUSER, and password: minisap.

abap1

 

Source code extractor

You need to code a small ABAP program that allows you to export the source code from SAP repository to the file system.

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.

Follow the steps below to install this extractor in our SAP system.

Installing the source code extractor

Once you have logged in to SAP, you need to open the ABAP editor. You can use the SE38 transaction for this purpose (see the red rectangles for main fields and actions):
2
In the next screen, fill out the program name: ZDTP_MASSDOWNLOAD, and click on ‘Create’ button:
3
Now, a new window will appear, where you will have to write a small title and set the type of program:
IMG4
Next step is to ‘Save’ this program as a Local Object:
IMG5
Editor window appears. Copy the contents from Mass Download 1.5.5.1.txt file and paste them. Finally, ‘Save’ the program.
IMG6
Once saved, the program needs to be activated to allow its execution:
IMG7

 

Executing source code extractor

Now, it is all ready to run our code extractor. Go to ‘Direct Processing’ menu option:

IMG8

The program form appears. Fill out the fields and export the source code to your file system:

IMG9

After running the program, you will get the source code files in the directory specified:

IMG10

 

Analyzing the code

If you are going to analyze your code in the cloud, make a ZIP file with the contents and upload it to KIUWAN in the ‘New Analysis window:

IMG11

Otherwise, if you prefer to analyze locally, use this directory as source directory in Kiuwan Local Analyzer:

IMG12