2 - ABAP Program Analysis
2 - ABAP Program Analysis
Introduction
Analysing
ABAP Messages
Analysing
Authorisation Errors
Analysing
Database Access
Data Declaration
Analysing
ABAP Program Terminations
Program Modularisation
Contents
Basic Debugging
Objectives
At the end of this unit, you will be able to:
sbc400_carrier .
wa_scarr TYPE scarr .
pa_car TYPE scarr-carrid .
START-OFSTART
OF-SELECTION .
START-OF-SELECTION
SELECT
SELECT SINGLE * FROM scarr
INTO CORRESPONDING FIELDS OF wa_scarr
WHERE carrid = pa_car .
IF sy-subrc = 0 .
IF
MOVE-CORRESPONDING
MOVE-CORRESPONDING wa_scarr TO sbc400_carrier..
MOVE
CALL SCREEN 100 .
MOVE-CORRESPONDING
MOVE-CORRESPONDING sbc400_carrier TO wa_scarr..
MOVE
WRITE :
wa_scarr-carrid ,,
wa_scarr-carrname ,
wa_scarr-currcode .
Chained
statement
ENDIF.
ENDIF
ABAP
key word
Comments
START-OF-SELECTION.
* Read data record from database table SCARR
Comment takes up
whole line
Comment on
rest of line
wa_scarr-carrid,
wa_scarr-carrname,
wa_scarr-currcode.
ENDIF.
comment.
sbc400_carrier.
wa_scarr TYPE scarr.
pa_car TYPE scarr-carrid.
wa_scarr-carrid,
wa_scarr-carrname,
wa_scarr-currcode.
ENDIF.
If you need more precise information on parts of the source code, you can analyze it.
The following slides explain the most important statements in the sample program.
The definition of the data objects are being read immediately after the program is
loaded. More precisely this is done when the system triggers an event named
Initialization. You cannot follow the processing of the data declarations in Debugger.
The Executable Source Code is being executed afterwards.
Ensure reproducibility
On Screens:
Remember:
Different objects may have the same name, e.g. data element and domain
Debugger
Trace Tools
10
F1 Help
Do
ub
lecli
ck
F1
Help
Data element
S_CARR_ID
Technical info
Technical info
SBC400_CARRIER
Field name
CARRID
Data element
S_CARR_ID
S_CARR_ID
Field type
DoFields
ub
lecl i
ck
CARRID S_CARR_ID
CONNID
...
Do
ub
Structure
le
-c
lic
Field Data
Structure type
SBC400FOCC
Technical types and technical domains may be directly assigned to data elements. If
you want more information on other data elements found within the same domain, you
can navigate to the domain from the data element by double-clicking and then executing
the function Where-used list.
11
Using SE16
SAP 2009 / Page 12
12
TABLES structures
All the data objects
created using DATA
Elementary data objects appear in the program object list under the Fields node.
From the object list, you can use the right mouse button to navigate to the part of the
source code where the data object is defined.
You can use the Where-used list function to display all lines of source code where the
data object is used.
Structures created using the TABLES statement are a special case. They are stored
under the object type Dictionary structures, for historical reasons.
13
Navigation Features
Help for local
data type declaration
F1
ABAP program
<type>
Types:
TYPES <user_defined_type> TYPE <type>.
Do
u
Help for local
data object declaration
F1
DATA:
<type>.Double-click
DATA <dataobject> TYPE <type>
bl
ec
lic
Navigates to local
data type declaration
or ABAP Dictionary
type declaration
F1
Keyword
documentation
for predefined types
Generally, data objects are typed using either a complete local program type or a
complete global type. Double-click the name of the type to display its definition. For local
program types this means: Navigate to the line in the source codes where the type has
been defined. For global program types this means: Navigate to the Dictionary and
display the global type.
You can use the complete predefined ABAP types directly, to provide a type for
variables. If you do so, double-clicking on the type after the TYPE statement has no
effect. For more information on pre-defined types, refer to the keyword documentation
on TYPES or DATA.
The following predefined ABAP types are complete:
d
Date: (YYYYMMDD)
t
Time: HHMMSS)
i
Integer
f
Floating Point Number
string character String (string, of variable length)
xstring byte sequence (heXadecimal string, of variable length)
You must define the length for these types.
c
Character
n
Numeric text (Numeric Character)
x
Byte (heXadecimal)
p
Packed number (= Binary Coded Decimals). You must enter the number of
decimal places.
14
Definition of a structure
(or of a structured field)
Do
ub
Do
leub
cli
leck
START-OF-SELECTION.
cli
ck
SELECT SINGLE * FROM scarr
scarr
INTO CORRESPONDING FIELDS OF wa_scarr
wa_scarr
WHERE carrid = pa_car.
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_scarr TO sbc400_carrier.
CALL SCREEN 100
100. Double-click
Definition of a screen
MOVE-CORRESPONDING sbc400_carrier TO(inwa_scarr.
the Screen Painter)
WRITE:
wa_scarr-carrid,
wa_scarr-carrname,
wa_scarr-currcode.
ENDIF.
You can display detailed information on single objects in the Editor by double-clicking:
Double-clicking the name of a database table displays the database table definition
using the ABAP Dictionary in the object window of the Object Navigator.
Double-clicking a field name displays the part of the program source code where the
Double-clicking will be a popup asking you weather youd like to create this object.
Use the Back function to get back to the program source code display in the Editor.
15
Editor
Help
START-OF-SELECTION.
SELECT SINGLE * FROM scarr
Editor Help
INTO wa_scarr
ABAP Overview
WHERE carrid = pa_car.
WRITE
ABAP Term
IF sy-subrc = 0.
ABAP News
MOVE-CORRESPONDING wa_scarr TO
ABAP Docu and Examples
sbc400_carrier.
CALL SCREEN 100.
MOVE-CORRESPONDING sbc400_carrier
WRITE
WRITE:
F1
ENDIF.
TO wa_scarr.
wa_scarr-carrid,
wa_scarr-carrname,
wa_scarr-currcode.
Keyword Documentation
Even for experienced Supporters it will often be necessary to get documentation about
ABAP statements to understand what is going on.
There are various ways of navigating to keyword documentation for an ABAP
statement:F1 on a keyword displays the documentation for the statement on which the
cursor is positioned.The Information icon displays a dialog box offering you various
views of the keyword documentation.
Apart from a precise description of the keywords the documentation provides a lot of
additional information including various examples.
16
By Double Clicking on a field you will navigate to ist definition (this is either in the source
code of the current program or in the ABAP Dictionary.
17
Call Graph
Via Utilities Call Graph Called by you can display a list containing all the modules
that call a particular module (form or program or screen etc)
18
Version Management
19
Version Compare
20
Modifications
21
Modification Assistent
Modification Overview
22
23
STOP
Editor
Navigation area
REPORT sapbc400wbt_getting_started.
Program
TABLES
sbc400_carrier.
DATA
wa_scarr TYPE scarr.
PARAMETERS pa_car TYPE scarr-carrid.
SAPBC400WBT_GETTING START-OF-SELECTION.
2 : Set breakpoint and
start
Execute
Direct processing
SELECT SINGLE
* program
FROM scarr
INTO CORRESPONDING
Debugging
WHERE carrid = pa_car.
Debugging
IF sy-subrc = 0.
MOVE-CORRESPONDING wa_scarr TO sbc4
1 : Get program name
CALL SCREEN 100.
using context menu
MOVE-CORRESPONDING sbc400_carrier T
SAPBC400WBT_GETTING
WRITE:/
wa_scarr-carrid,
wa_scarr-carrname,
-> Debugging.
Using a breakpoint in the Editor: You can select a statement in the program that the
runtime system in Debugging mode should switch to. To do this, navigate to the line in
the program, select it, and choose the Breakpoint icon (that is, the STOP sign). Then
start the program, either by choosing Execute -> Direct processing or F8.
24
System
Help
/h
+ Enter
Utilities
Debugging Screen
Debugging ABAP
2 : By entering /h in the
command field
You can also switch to Debugging mode by typing /h in the command field in the tool
bar, followed by Enter.
25
SAP
ABAP Debugger
H
chws
Watchpoint
Felder
ZJJ_KURS_000
SingleZJJ_FORMS
step
Quelltext von
Hauptprogramm
Festpunktarithmetik
15 30 5
SY-SUBRC
SY-TABIX
SY-DBCNT
BIN (1) (000)
ds0025 INS
o
Starting the program in Debugging mode allows you to execute the program line by line
using the Single Step icon. You can display up to eight variables. To trace the variable
values, enter the field names in the left input field. You can also see this entry by doubleclicking the field name in the code displayed.
26
SAP
ABAP Debugger
H
chws
Watchpoint
Felder
Fields
Main program
Source code of
ZJJ_KURS_000
ZJJ_FORMS
pa_car
LH
You can trace the field contents of up to eight data objects in debugging mode by
entering the field names on the left side or by creating the entry by double-clicking on a
field name.
You can change field values at runtime by overwriting the current value and pressing the
Change icon.
27
H
chws
Watchpoint
Fields
Main program
Source code of
ZJJ_KURS_000
ZJJ_FORMS
You can trace the field contents of a structure by entering the name of the structure in the
left column. The field view of the structure is displayed if you double-click on this entry.
28
SAP
ABAP Debugger
H
chws
Watchpoint
Fields
ZJJ_KURS_000
Main program
ZJJ_FORMS
Source codeContinue
of
SY-SUBRC
SY-TABIX
SY-DBCNT
BIN (1) (000)
ds0025 INS
o
You can set a breakpoint by double-clicking in front of a line of source code in the
debugging mode. If you then click on the Continue icon, the program will be executed up
to the point where the next breakpoint is defined (or up to the next screen).
When you have already entered the Debugger you can also create a breakpoint from the
menu by choosing. Breakpoints can be placed at:
ABAP Statement
program
will stop at any select statement
Function module,
executed)
Form,
will
stop whenever you enter this form.
System Exception
You can also create a breakpoint before you start debugging. This can be done in the
ABAP Editor.
You can find information on content-related breakpoints in the ABAP Statements and
Data Declarations unit.
29
The call stack shows the current call hierarchy (which program was called by which
program)
It is always possible to switch to the other levels of the hierarchy. Within this level it is
possible to access all variables and their values but you have to keep in mind that only
the local variables have their current values; global variables might have been changed
in the meantime. The switching itself is triggered by double-clicking on the desired level.
Please always keep in mind ,that you only see the simple call hierarchy. If the program
jumped to another routine and returned you are not able to find a trace in the call stack.
(For this task use ABAP Trace (SE30))
If system debugging mode is off, then you will not see system modules in the stack !
(switch on system debugging: /hs)
30
31
32