SAP System Setup Training Course
Reveals How To Setup A Free SAP Developer System.
Learn SAP & Practice For Certification. Developer Tips Included:

ABAP Workbench – How To Use System Logs And Short Dump Analysis

Following on from a previous article ‘ABAP Programming With The ABAP Workbench – The Tools You Must Learn And Master‘, where we went through how you can use some of the SAP workbench development tools to quickly analyze our ABAP code and improve your program performance; we will now learn how to troubleshoot our ABAP code when it returns a runtime error.

There are many reasons why a run-time error can occur such as un-handled exceptions, a resource or system problem or an error in coding. Let’s look a little deeper…

Tools for Troubleshooting Your ABAP Code

System Logs (TCODE – SM21)

When faced with a program that crashes, developers end up spending a lot of time debugging ABAP code to find and trace what went wrong. But they should know that SAP records all the warnings, exceptions and system errors in the System Log. So, when we get an error we can make best use of time by taking a good look at the System Logs first to help find and correct the errors in our code quickly and easily.

System Logs Go To Transaction SM21

System Logs Go To Transaction SM21

To view the System Logs goto transaction SM21.

These are the different types of logs created by system log:

  1. Local System Logs
  2. Remote System Logs
  3. All Remote System Logs
  4. Central System Logs

In this tutorial we will see how to view the Local System logs, but the process is same for the other types of log files.

Click on the System Log menu button, select ‘Choose’ and you will see the different types of logs. Select ‘Local system logs’.

System Log Menu Button "Choose"

System Log Menu Button "Choose"

 In the selection screen you have the option to provide the period, user, transaction, process and the program class.

After entering the details hit the F8 button or you can click on the ‘Reread System logs’ button provided at the top of the screen.

After execution is completed you will have a table with the system log entries depending on your selection criteria.

Table With The System Log Entries

Table With The System Log Entries

By double clicking on a specific entry you can view the detailed information.

Table With The System Log Entries

Table With The System Log Entries

Always use SM21 as a starting point to analyze an ABAP program for dumps and errors.

ABAP Runtime Error/ ABAP Dump Analysis (TCODE – ST22)

A runtime error is triggered when there is an un-handled exception or a system error in an ABAP program. By the help of this recorded runtime error you can pinpoint the problem and get to the solution quickly. To start the ‘ABAP Runtime Error’ go to Transaction code ST22.

ABAP Run Time Error

ABAP Run Time Error

You will find the standard option in the selection screen i.e. ‘Today’ and ‘Yesterday’ with the total number of run-time errors that have occurred during these periods.

Standard Option In The Selection

Standard Option In The Selection

In the ‘Own Selection’ section you can provide your own filters such as date, time, user and other parameters.

Own Selection Option You Can Provide Date, Time, User And Other Parameters

Own Selection Option You Can Provide Date, Time, User And Other Parameters

At the bottom of the screen you will find three important check boxes which by default are not selected.

  1. With information on Exception/Short Text of Runtime Error: Selecting it you can see the ‘short text’ of the runtime error with concise information. You can then navigate to the ‘Long Text’ from there
  2. The program affected: Selecting it you can see the program affected.
  3. Program and associated application components (long runtime): Selecting this check box you can see detailed in-depth relating to the program and its associated components.
Three Important Checkboxes

Three Important Checkboxes

If the runtime error is occurred today then you can press the push button ‘Today’ to go to the list of runtimes errors today.

ABAP Runtime Errors

ABAP Runtime Errors

Double clicking on a row will take you to the ‘Runtime Error Long Text’

Runtime Error Long Text

Runtime Error Long Text

Short Text: It gives us a short description of the runtime error.

What Happened?

What Happened?

What Happened? : This section gives the name of the program which requires correction.

What Can You Do?

What Can You Do?

What Can You Do? : Here you can see some suggestions.

Error Analysis

Error Analysis

Error Analysis: This section often provides really detailed information about the possible causes of the runtime error.  This section is really important and you should go through it to get a head-up about the exact cause of the error.

How To Correct The Error

How To Correct The Error

How To Correct The Error: Here you will find some information on how you can possibly correct this error. Often by following the steps given in this you can correct your code or at least it will point you in the right direction.

Source Code Extract

Source Code Extract

Source Code Extract: This section gives the exact line number on the code where the runtime error was triggered. By double clicking on this you can navigate to the source code. This is very useful because it saves a lot of your time and without debugging you know the location of the bug which caused the runtime error.

The other sections provide you information regarding the list of variables and the programs affected.

In this tutorial we have seen that it is always a good idea to first analyze the logs and dumps before just blindly debugging your ABAP program which in turn helps you solve your coding issues in the least amount of time possible.

Categories

About the Author:

Pete has been working with SAP technologies for over 10 years. He started out as an ABAP consultant and then moved on to BW where he has worked many different clients covering a wide variety of industries. "I love introducing SAP technology (especially BI) to new clients and showing them how they can go from zero to hero within their business in super fast time". Contact me on twitter @PeterMoxon