Beruflich Dokumente
Kultur Dokumente
Purpose
The Code Inspector is a generic tool that you use to check SAP repository objects.
You use it to define inspections which examine object sets with the help of check
variants. It checks the performance, security, syntax, and adherence to naming
conventions of individual or sets of repository objects. You also use it to retrieve
statistical information or to search for certain ABAP tokens. As a result of an
inspection, you receive information, warning, and error messages about the
different properties of the examined objects.
To start the Code Inspector, perform one of the following:
Choose SAP Menu Tools ABAP Workbench Test Code
Inspector.
From the SAP Easy Access, enter transaction code SCI.
Features
The Code Inspector comprises the following elements:
Inspection, where you can perform checks on an object.
You can display, create, change, copy, create a new version of, delete, and see
the results of an inspection.
Object set, where you can determine the objects to be checked.
You can display, create, change, copy, and delete an object set.
Check variant, where you can define the individual checks that are performed
on the objects.
You can display, create, change, copy, and delete a check variant.
Constraints
The range of functions of the Code Inspector is limited to checking static object
definitions and can only point out certain problems. For example, it cannot give a
precise prediction of the overall program performance. To do this, you need to
analyze the program execution at runtime, using the Runtime Analysis (transaction
code SAT), the Performance Analysis (transaction code ST05), the Global
Performance Analysis (transaction code ST30), or another relevant tool.
ABAP Unit
Purpose
Automated tests could help to recognize such changes which break the existing
code. Unit testing is a technique that enables testing during development.
Dedicated test classes invoke the tested program and compare the result with the
expectation. ABAP Unit implements this technique. ABAP Unit is integrated both in
the ABAP runtime and in the ABAP Workbench, which facilitates the writing of tests.
Page 1 of 74
Features
The key features of ABAP Unit are the following:
Tests are written in ABAP itself. You do not have to use additional tools or
scripting languages.
The program being developed can be checked from within the editor.
The integrated coverage analysis helps to identify code which is not tested.
An adapter that is embedded in the Code Inspector allows you to execute
multiple tests.
To write a unit test is to write a dedicated local test class within the main program.
An integral part of the program the test class and the code being tested is one
transport object. This ensures that test coding and tested coding always have the
same version.
ABAP Unit identifies all test classes and invokes them to check the code being
tested. A service class allows the test classes to analyze the state and raise
assertions if necessary.
If you have all the code tested, the integrated coverage analysis help you to identify
which code was actually invoked from the test classes. The source which was not
executed can be highlighted in the edit control.
The adapter to the test framework Code Inspector offers the power to run multiple
tests such as all unit tests within one development package.
Page 3 of 74
Navigation
On the initial screen, you can start and stop trace recording. The measurement
results are saved in a trace file after execution of the program to be analyzed.
You can restrict the quantity of performance data displayed using a display filter and
by defining selection criteria.
The performance data can then be displayed, either in the form of a basic trace list,
an extended trace list, or atime-sorted trace list.
You can manipulate the display of data even further:
With Edit SQL Statement, you call up the appropriate editor.
You call up a description of Dictionary objects through the display DDIC
Info. From here you can easily branch to the definition in the DDIC.
Using Detailed Info, you can call up a detailed display for the statement to be
analyzed.
You can determine identical Select statements easily through the
display Identical Selects.
Using the Summary function, you can summarize a trace list by statements or
tables.
In addition, you can display an execution plan for a selected SQL statement
using Explain SQL.
Using the function List Sort, you can sort the trace records according to different
properties for example, transaction name, process ID, process type, or even
stored sequence.
Using the function Display Long Name, you can display the extended names for
the objects or program.
Page 4 of 74
You can branch from the display of performance data for a statement to the
appropriate source code in the ABAP Editor.
Initial Screen
Calling
You can call the initial screen of the test tool using transaction code ST05 or by
choosing Test Performance Trace in the ABAP Workbench.
Functions
The following functions are available on the initial screen:
Select trace:
Select the trace mode SQL Trace, Enqueue Trace, RFC Trace, or Table Buffer
Trace. You can select mutliple trace modes simultaneously.
Select trace function:
Start the trace recording.
Stop the trace recording.
Page 5 of 74
Trace files are managed by the system. Thus they can be saved,
like any other object; saved trace files can be displayed and deleted.
Trace Status
A trace can only be activated once on any application server. The Trace
Status display informs you whether another user in the system has already
activated a particular trace.
analyze the results later on, remember that the data in the trace file can be
overwritten (see above).
1. Choose the menu path Test Performance Trace in the ABAP Workbench.
The initial screen of the test tool appears. In the lower part of the screen, the
status of the Performance Trace is displayed. This provides you with information
as to whether any of the Performance Traces are switched on and the users for
which they are enabled. It also tells you which user has switched the trace on.
2. 2. Using the selection buttons provided, set which trace functions you wish to
have switched on (SWL trace, enqueue trace, RFC trace, table buffer trace).
3. 3. If you want to switch on the trace under your user name, choose Trace on.
If you want to pass on values for one or several filter criteria, choose Trace with
Filter.
Typical filter criteria are: the name of the user, transaction name, process name,
and program name.
4. 4. Now run the program to be analyzed.
If you are shown trace kernel errors on the initial screen (for example,
not enough storage space available), you must first remove the errors
or have them removed by your system administrator.
Page 7 of 74
The results of the trace recording are stored to ten trace files.
Overwriting trace records, however, cannot be entirely excluded in this
case either.
The Performance Trace records all database access calls, table buffer
calls, remote calls, or calls for user lock activity. These measurements
can affect the performance of the application server where the trace is
running. To preserve system performance, you should therefore turn off
the traceas soon as you finish recording your application.
For performance reasons, you should switch off the traces as soon as
you have finished recording.
Procedure
To deactivate the trace:
Page 8 of 74
5.
When you display the trace records, you can choose between a basic list and an
extended list. Both lists display an overview of the logged actions and performance
data. In addition, you can display a trace list sorted by time.
For more information, refer to:
Displaying Lists of Trace Records.
In both lists the simple trace list and the extended list you have the same range
of functions for analyzing the listed statements and other performance data.
The time-sorted trace lists is only slightly different from the trace lists mentioned
above. For more information on the transaction, process type, client, and user, call
up the function Display->User, Transaction and so on in the Goto menu.
Display Filter
Prerequisites
You have switched off the performance trace and have opened the display filter
after choosing Display Trace or the corresponding menu entry from the initial screen
of the performance trace.
Use
You can use the display filter (Set Restrictions for Displaying Trace) to restrict the
number of logged trace records that are displayed on the basic list (Trace List),
detailed list, or time-sorted list.
Page 10 of 74
Features
If you do not enter any selections, all of the trace records are selected.
Specifying the Trace Type to Display
The SAP system also initializes this parameter from the system environment. The
default trace type is SQL trace. If you start the display filter directly after the
recording, the trace type appears as it was last configured.
Specifying the Trace Interval
The system initializes the trace interval from 00:00:00 to the current system time on
todays date. However, if you start the display filter directly after the recording, the
trace interval is set from the start time to the end time of the recording.
Note that if you are working on a distributed system, where the clocks
on the database server and the application servers are not
synchronized, any times determined automatically by the system may
be inaccurate, which in turn may mean that not all trace records are
displayed.
Page 11 of 74
Other Filters
You can also filter the trace record display using the following parameters:
User
Objects
Duration
Operations
Page 13 of 74
Page 14 of 74
The first line of the list contains a subheader, which remains unchanged for all trace
records of a program to be analyzed. It contains the following information:
- Name of the transaction, process identification number, process type, client, and
user name.
The next line contains the following headers:
Duration Execution time of the statement. The time is displayed in the format
milliseconds.microseconds.
Object name
SQL trace record: Name of the database table
Enqueue trace record: Name of the lock object
RFC trace record: Shortened name of the instance on which the function
module was executed
Buffer trace record: Name of the buffered table
Oper
SQL trace record: Name of the operation to be performed on the database.
See also: Measured Database Operations
Enqueue trace record: Name of the lock operation
RFC trace record: Client | Server. (If a function is specified as the Client, this
means that it wass calledremotely. If it is specified as the Server, this
means that the function was made available and executed.)
Buffer trace record: Buffer operation
Page 15 of 74
statement and list the variables separately. If there are no variables, the two display
forms are identical. To display the statement, double-click its short form or the menu
option Detail, or click the magnifying glass icon.
To replace the placeholders with the current variables, choose the pushbutton
Replace Placeholder in the SQL Statement, or choose the appropriate menu option.
Displaying Information about DDIC Objects
If you wish to look at the Dictionary description for the object (table or lock object)
to which the statement refers, position the cursor on the object and choose DDIC
info. Alternatively, you can choose the same function from the menu. If the current
statement contains several DDIC object (for example, a join), the Object Name row
contains the first object to appear in the statement.
If the log entry is an RFC entry, the column contains a shortened version of the
name of the instance on which the function module is executed. In this case, you
cannot display a Dictionary definition.
You can display further DDIC Dictionary information by opening the actual definition
of the object in the DDIC. For more information, refer to Finding Dictionary
Information.
Execution Plan for SQL Statements
To display the execution plan of a selected SQL statement, place the cursor on the
statement and choose the pushbutton
statements for which an execution plan can be displayed depends on the database
system that you are using. The execution plan for a SELECT statement under
the Oracle database system looks like this:
Display Call Positions in the ABAP Program or the menu option of the
Note that the source code cannot always be displayed. For example, if
the call comes from the SAP kernel, you cannot branch to the program
code.
Identical Selects
When you are analyzing a trace log, it can be particularly useful to find out if there
are any identical select statements. You can do this by choosing the menu
option Identical selects in the menu Trace List. The system compiles a list of any
SQL statements that are executed more than once. You can then eliminate any SQL
statements that are repeated or superfluous.
Page 19 of 74
Page 20 of 74
Embedded SQL
One of the difficulties of connecting a programming language with an SQL interface
is the transfer of retrieved data records. When the system processes an SQL
statement, it does not know how big the result will be until it has made the
selection. The result consists of table entries, which all have the same structure.
The system has to transfer these records to the calling program in the form of a
data structure, for example an array, that is known to the calling program.
The disadvantage of an array is its static definition. You have to specify the size of
an array before runtime. However, because you cannot know the size of the dataset
the system will return, you must define a very large array to avoid an overflow.
To circumvent this problem, the SAP System translates ABAP Open SQL statements
into Embedded SQL. To do this, the system defines a cursor. The cursor is the
logical connection to the selected datasets in the database and is used to regulate
the data transfer between ABAP programs and the database. See also Database
Operations.
During every FETCH operation, the database passes one or more data records to the
database interface.
Defines a new cursor within an SAP work process and assigns the SQL
statement to this. The short form of this statement is displayed in the list of the
trace records underStatement. The cursor is given a unique number, the cursor
ID. The cursor ID is used for communication between the SAP System and the
database system.
PREPA
RE
OPEN
Opens a cursor for a prepared (converted) SELECT statement. OPEN passes the
parameters for the database access. OPEN is used only for SELECT statements.
FETCH
Passes one or several records selected from the database through the SELECT
statement to the DB interface of the SAP System. The selected data is identified
Page 21 of 74
Opens again a cursor that the system has prepared for a SELECT statement and
passes the new parameters to the database.
EXEC
Transfer of the parameters for the statement from the database and execution
of the statement that change data in the database (for example, using UPDATE,
DELETE, or INSERT).
REEXEC Opens again a cursor that the system has already prepared for a previous EXEC
statement.
Buffering
The SAP System ensures that data transfer between the SAP System and the
database system is as efficient as possible. To do this, it uses the following
techniques:
Page 22 of 74
Table buffering. The program accesses data from the buffer of the application
server.
Database request buffering. Individual database entries are not read or passed
to the database until required by an OPEN SQL statement.
When you analyze trace records, you should also examine the system's buffering
mechanisms.
Table Buffering
For tables can be either partially or fully buffered (refer to Buffering Database
Tables.), an OPEN SQL statement only accesses the database if the results of the
statement are not already in the buffer Consequently, the SQL Trace does not
contain a command or command sequence for every OPEN SQL statement. On the
other hand, every SQL statement in the trace file has been sent to the database and
executed.
Buffering of Database Requests
To keep the number of runtime-consuming PREPARE calls small, each an
application's work processes hold a certain number of already translated SQL
statements in a special buffer. By default, a process holds up to 250 statements.
If the system must execute a specific OPEN SQL, the system first checks whether
this statement is stored in the "Statement cache". If the statement is in the cache,
the system executes it immediately using a REOPEN (SELECT) or a REEXEC (INSERT,
UPDATE, DELETE).
If the statement is not buffered, a PREPARE operation prepares it for the subsequent
OPEN/EXEC. The system administers the buffer according to the LRU algorithm
("least recently used"). When space is needed for new statements, the statements
that are rarely used are deleted. As a result of the LRU algorithm, the statement
must prepare frequently used statements usually only once.
An application server buffers the DECLARE, PREPARE, OPEN, and EXEC requests
within the cursor cache of one work process. As a result, once the system opens a
cursor for a DECLARE operation, it can use this cursor over and over again within
the same work process.
Page 23 of 74
Read Access
The first screen of the SQL trace file displays each measured database request the
application made. The trace file records when the request occurred and its duration.
The ABAP Dictionary table involved in the request is also listed.
A trace file for a read access of the table SFLIGHT might look like this:
Opens the cursor and specifies the selection result by filling the selection fields
with concrete values. In this example, the field 'MANDT' receives the value
'000' and the field 'CARRID' receives the value 'LH'. The OPEN operation then
creates a set of retrieved records.
FETCH
Moves the cursor through the dataset created by the OPEN operation. The
array size displayed beside the fetch data means that the system can transfer
a maximum package size of 392 records at one time into the buffered area.
The system allocates this space on the application server for the SFLIGHT
table.
In the above example, the first FETCH retrieves the maximum number of
records from the dataset. Then, the these records are transferred to the
program interface.
Page 24 of 74
Write Access
An sample SQL file analyzing a request that changes data in the Table D010SINF
might look like this:
The example shows the system inserting new records into the table (INSERT). As in
the first example, where the system carried out a read-only access, the system
needs to prepare the database operations (PREPARE) that change the database
records. The PREPARE operation precedes the other operations.
Options:
Object Name
SELECT STATEMENT
ID
PAID
POS
FLLOG
FLLOG___0
QUERY PLAN
SELECT STATEMENT
Page 25 of 74
FLLOG
FLLOG___0(UNIQUE)
Operation attributes.
OBJECT
NAME
ID
PAID
Specifies the ID number that the current operation transfers its results to.
This is important if nested accesses on various hierarchy levels are involved.
Position
Identifies the next number for operations working on the same hierarchy
level.
In the example above, the key is fully qualified. The database can use the primary
key index FLLOG__0 to access the table records. Every transparent table in the ABAP
Dictionary has a primary key. The system automatically creates an index for this
key. The primary key index is also unique, meaning that there is only one index
entry for every line in the table. As a result, the system uses the UNIQUE SCAN
operation.
The UNIQUE SCAN has the ID 2 and parent ID 1. This means that the operation
passes its results to the operation with ID 1. ID 1 belongs to the TABLE ACCESS
operation. TABLE ACCESS can directly access one record because of the uniqueness
of the BY ROWID index. Once the system chooses an access strategy, it sends the
SELECT statement with ID 0 to the database.
If the SELECT statement does not specify a fully qualified key, the database could
be forced to read the records using a FULL TABLE SCAN. In this case, no index is
available and the database reads the entire table in packages.
If the index is ambiguous, the database uses a RANGE SCAN. The RANGE SCAN
scans over an index area that might contain several sets of retrieved data.
The NESTED LOOP operation exists for nested reads where several indexes are
joined together within one database access.
1.
Place the cursor on a line containing the database request you want
explained.
2.
Choose Explain..
The Explain screen shows you the database's strategy for carrying out the
selected operation.
If you are working with an Informix database and you display the explanation for the
following statement:
select owner from systables where tabname = 'atab'
The system provides the following explanation:
Execution plan of a select statement (Online Optimizer)
QUERY:
SELECT OWNER
FROM SYSTABLES
WHERE TABNAME = ATAB
Estimated Cost: 1
Estimated # of Rows Returned: 1
1) informix.systables: INDEX PATH
(1) Index Keys: tabname owner (Key-Only)
Lower Index Filter: informix.systables.tabname = ATAB
The fields in the explanation have the following meanings:
QUERY
Estimated Cost Estimates the database expenditure required to execute the statement.
The cost-based optimizer estimates this value in terms of the I/O and
CPU required by the statement. The larger the
Estimated Cost the greater the expenditure.
Estimated # of Estimates the number of table rows that the SQL statement will return.
Rows
Returned:
Immediately below the number of rows returned is the selected execution plan. In
the above example, the execution plan is as follows:
1) informix.systables: INDEX PATH
The
1) indicates that the system processes the systables table as the first step of the
execution plan. For queries that span several tables (views and joins), the
numbering sequence indicates the order the system processes the tables. In this
example, only a single step was needed.
The execution plan specifies the type of table access. In the above example, the
access was the
INDEX PATH . Access to the required data row is made using the index of
the systables table. Normally, the execution plan uses the primary key as an index.
Every transparent table in the ABAP Dictionary has a primary key and the system
automatically creates an index for this key.
Page 27 of 74
When the system must read a large proportion of a table, the system
does not use the primary key as an index.
For this example, the system did not need to read the row that corresponds to the
index key. The information that was required was present in the key itself. The
explanation indicates this using the phrase
Key-Only as follows:
(1) Index Keys: tabname owner (Key-Only)
If a SELECT statement is specified without a fully-qualified key, the database may
need to read the relevant rows with a FULL TABLE SCAN. In this case, you will not
see an index in the SQL-Explain output but instead you will see something like the
following:
1) informix.systables: SEQUENTIAL SCAN
This indicates that a read of the entire table is necessary (FULL TABLE SCAN).
With more complex operations, where the combination of results from several
SELECTS on different tables is required, you will see further strategies mentioned
(such as MERGE JOIN, DYNAMIC HASH JOIN). These refer to the join strategy chosen
by the optimizer.
Page 28 of 74
Features
While the enqueue trace is switched on, the system records all of the locking and
unlocking statements that occur for a user or group of users.
The trace recording contains the following information:
Lock statements executed
Table names of the lock event
Name of the program that set the lock
Type of lock
Lock owner
Total time required for the lock
Time required by the enqueue server to release the lock
For further information refer to:
Enqueue Trace Records
Detailed Display of Enqueue Trace Records
Page 30 of 74
Time Time required by the enqueue server to execute the lock (server time, in
milliseconds). If the). In the case of an asynchronous call, or no server being
requested, the time is zero.
ABAP-Programname Name of the ABAP program that requested the lock.
Number of granules.
Lock-Mode Type of lock.
Table Name Table name of the lock object.
Granularity Argument Lock argument.
Page 32 of 74
Page 33 of 74
Features
While the buffer trace is switched on, the system records all buffer accesses of a
user or user group.
The table buffer trace tells you:
Which buffer accesses your statement executes
Which buffer operations are used
How the buffer is managed
Additional Functions
Page 34 of 74
Procedure
To save a list locally:
8.
9.
Alternatively, you can download the file into the buffer if you
choose unconverted in item 6 above.
From the list display of a trace file, you can select a Dictionary table and get
details on the access method.
See also Analyzing Trace Records
Note that the result of the Explain for SQL Statement function
are database-specific. This concerns both the SQL statement and the
operation. With some DB systems, Explain for SQL Statement can only
be executed for the SELECT statement. To be able to understand the
results, you require sound knowledge of the relevant database
system. You should refer to the manuals provided by the manufacturer
of the database system you are using.
Analyzing an SQL Statement without a Trace File
To retrieve an analysis of an SQL trace without creating a trace file, proceed as
follows:
16. 1. On the Performance Trace initial screen, choose Enter SQL Statement.
The system starts an editor with which you can enter an SQL statement. You can
also load an SQL statement from an internal table or local file or save it in one.
17. 2. Enter an SQL statement.
Page 36 of 74
table's primary key. If other indices were created within the ABAP Dictionary, the
system lists these also.
25. 7. Choose Table/View fields.
This function branches from the trace list to the table definition in the ABAP
Dictionary.
Procedure
To access the summarized lists from the trace list, the detailed trace list, or the
time-sorted list, choose Trace List Summarization Function (summarize trace by
SQL statements, display identical selects, Summarized table accesses).
You can use the F1 help to obtain information about the column contents of the
individual lists.
Results
Function Summarize Trace by SQL Statements
The following columns are displayed in this list:
Executions: Total number of executions of the statement.
Identical: Percentage of "value-identical" select statements of the "statementidentical" select statements.
Page 38 of 74
Page 39 of 74
Where Clause: The where clause of the SQL statement. If the clause ends with
the character string ..., it was truncated.
For further analysis of this summarized list, a range of functions is available such as
sorting by column, selecting rows or parts of rows with subsequent summarization.
******************************************************************************
Page 40 of 74
Code Inspector
Use
The ABAP Workbench offers a variety of tools for doing static and dynamic checks of
the correctness of your programs and other objects.
The Code Inspector resolves the question of how to use these separate tools
comfortably and efficiently.
With the Code Inspector, you can run all of ABAP's checking tools at one time. You
can also choose which tools you want to run.
Uses: If you are a Developer, you can use the Code Inspector for the following
tasks:
Ad hoc inspection definitions and results are not saved - you use them to check
objects on which you are currently working. The definitions and results of re-usable
inspections are saved. You can define re-usable inspections to check larger sets of
objects or track your errors over time.
If you are a Quality Manager, you can do the following with the Code Inspector:
Define public re-usable code inspections. Other users - for example, other
QMs - can use these inspection definitions and their results.
Change the priority of check messages and get an overview of the available
checks, documentation, and handling of check messages.
For these functions, choose Goto Management of Message Priorities . Table
entry in theException column means that an exception can be requested. Where
a pseudo comment is shown, a message can be masked.
Page 42 of 74
Or mark the program or other entity and use the context menu. The path is the
same.
2.
The Code Inspector presents the results of the checks. Here, the display is
opened to show an error and two warnings. These are in the categories Analysis
of WHERE Condition for SELECT and Low Performance Operations on Internal
Tables.
Page 43 of 74
Not all problems can be masked with a pseudo comment. In these cases,
choosing
instead lets you request an exception. (Where you don't see
an Exceptions icon, the check message cannot be masked at all.)
To request an exception, you need to specify the name of a user authorized to
grant it, the scope of the exception, and optionally a comment. Once you save
the exception, you can see it from the entry screen of transaction SCI.
Choose Goto Exceptions Requested .
Note: For a complete list of messages with documentation and exception
handling, choose Goto Management of Message Priorities . Table entry in
the Exception column means that an exception can be requested. Where a
pseudo comment is shown, the message can be masked.
Useful Ways to Go On
Here are some useful things you can do from the Results screen of the Code
Inspector.
Define Your Own Check Variant
In an ad hoc check, the Code Inspector uses the system-wide DEFAULT check variant
to decide what to check.
For future checks, you can create your own personal DEFAULT check variant. The
Code Inspector will then use your check variant instead of the system default.
1.
On the Code Inspector: Results screen, choose .
2.
You will see the checks selected for the system DEFAULT check variant. Mark
or unmark the checks to put together the code inspection that you wish to have.
You may need to specify check parameters for some tests before you can
activate them.
Note: Marking Dynamic Checks tells the Code Inspector to run your ABAP Unit
tests. To this extent, the Code Inspector can do dynamic runtime checks as well
as static checks.
3.
Save your personal DEFAULT check variant. The Code Inspector will use it in
ad hoc runs from now on.
To use the system DEFAULT check variant again, just use transaction SCI to delete
your DEFAULT check variant.
Use a Compact Results Display
For a more compact Results display, try the table display. Click on the
button.
Mail Check Results
Some or all of the problems don't really belong to you? Then you can mail them to
the real offender:
1.
Choose the
function to switch to the list display.
2.
Choose the
function to enter e-mail addresses and a cover note.
3.
Choose
to dispatch your results mail.
Page 44 of 74
2.
3.
or
On the screen which follows, you define the ad hoc inspection. Just as in a
reusable inspection, you can choose from existing object sets and check
variants or define new ones.
You can also inspect the entities in a transport request or specify single programs
or other entities. And you can define a temporary check variant by marking and
unmarking the checks you would like to run.
4.
Run the inspection. The Code Inspector presents the results screen
automatically.
Here, the display is opened to show an error and two warnings. These are in the
categories Analysis of WHERE Condition for SELECT and Low Performance
Operations on Internal Tables.
Page 45 of 74
or the
3.
You can also inspect the objects in a transport request, or specify programs or
other components by name.
4.
5.
Choose
... (Execute) to run the inspection asynchronously. The most
interesting option is to run the inspection as a background job. For this, enter a
server group (click on
and mark the In Background (Periodically also) field.
With this option, you can run the inspection periodically. This is a good way to run
ABAP Unit tests automatically.
6.
Wait for the results. The screen shows when the inspection has finished (you
may need to refresh the screen with Display <-> Change). You will see one of
these icons next to the Inspection field.
The inspection has not yet run or has not yet been completed.
You can also pick up the results later. Just use the F4 Possible Entries function of
the inspection Name field to access inspections that have already run.
7.
Here, the display is opened to show an error and two warnings. These are in the
categories Analysis of WHERE Condition for SELECT and Low Performance
Operations on Internal Tables.
Page 48 of 74
If you would like to re-check the objects after making corrections, just click on
the
button.
The Code Inspector creates a new version of your inspection, and you can run it
again.
Page 49 of 74
You must designate one or more users with full Code Inspector
authorizations to review and approve exceptions. You must tell your developers
which users are responsible for their exceptions.
Developers apply for exceptions from the results of code inspections. To complete
an exception request, a developer must enter the name of the user who should
review the request.
You should use the Code Inspector in your consolidation or Quality Assurance
test system only. Do not let developers apply for exceptions in their development
systems.
The reason: Exceptions are system-local entities. They cannot be transported.
You should use and manage exceptions only in a stable, long-lived Quality
Assurance system. Otherwise, the exceptions can get lost, so that hidden errors
are reported once again.
In practice, this limitation means that developers should use the Code Inspector
in the QA system. Only there will check messages be hidden by exceptions.
Requested
Page 50 of 74
3.
4.
2.
Click on the F4 icon at the Name field in the Inspection frame on the start
screen of the Code Inspector (transaction SCI).
3.
The Code Inspector displays a window with the available inspections. The
highest version number is of course the newest instance of an inspection.
Click on an entry in the list to fetch the inspection. You can then select
the saved results.
to see
The Code Inspector provides a convenient way to automate ABAP Unit testing. You
can, for example, run ABAP Unit tests automatically every week after transports
arrive, in order to do regression testing and verify new functions.
Note
You will find a weblog in SDN with detailed instructions for setting up automated
ABAP Unit testing with the Code Inspector (English
only): http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/16420
To set up automated ABAP Unit testing, do the following:
1.
Define an inspection and select the programs whose ABAP Unit tests should
run.
2.
Define a check variant in which you mark only Dynamic Tests in the List of
Checks.
3.
Choose
shown here:
... (Execute) to run the inspection. Fill out the execution options as
Confirm your choices. On the next screen, you can enter the start time and
repeat interval of the Code Inspector job. The job will automatically repeat the
ABAP Unit tests that you have selected.
With the check Search of ABAP Tokens, you can look for text strings in literals,
comments, and in active coding. Enter the search string by clicking on the
button.
SAP recommends for best results that you start and end the search string with
the wild card character:*string to search for*. The search is case-insensitive.
With the check Find Unwanted Language Elements, you can search for ABAP
statements that are obsolete in modern ABAP OO programming. The check is
delivered with a pre-selection of statements.
2.
Save the check variant and use it to search for texts and statements that you
wish to change.
Utilities
SAP Internal
But you can still send lists of messages to users. This is a good way to report results
from a consolidation system to developers who work in other systems.
1.
2.
3.
For R-Mail within the SAP System, you can specify a user ID as
the Recipient and B SAP Logon Name as the Recip. Type.
For external Internet mail, you can enter an Internet e-mail address
(user.name@domain) and U Internet address as the Recip. Type. For external
mail, SAP Connect (transaction SCOT) must be set up.
4.
Press
Page 53 of 74
You can have the Code Inspector automatically check the objects in a transport
request when the request is released.
To activate this feature, do the following:
1.
2.
Administration
Global Customizing
3.
In the Check Objects when Request Released frame, mark the Globally
Activated option.
The Code Inspector will automatically start when a user releases a transport
request. (The Code Inspector does not run if a user releases a task within a
transport request.)
The user will see a status message reporting that the Code Inspector is checking the
objects in the transport request. The system DEFAULT check variant is used for the
check.
If no check messages are reported, then the release of the transport request is
completed, as usual.
If there are check messages, then the user has the option to review and correct
them before the release of the request is completed. The user can also override the
checks and complete the release of the transport request despite the presence of
check messages.
*************************************************************************************
******
Page 54 of 74
You can call the Code Inspector for the relevant single objects directly from the
ABAP Editor (SE38), the Function Builder (SE37), or the Class Builder (SE24) (Object>Check->Code Inspector). The system then checks using a default check variant
which is provided by SAP.
SE38
SE37
Page 55 of 74
So in this post I will give an overview of how we can use the potentials of code
inspector and how we can pin point the errors and deliver the best quality code with
adherence to ABAP coding guidelines.
What is Code Inspector?
The Code Inspector is a tool for checking Repository objects regarding
performance, security, syntax, and adherence to name conventions.
Using the Code Inspector (transaction code SCI), you can check individual objects
or sets of objects for performance, security, syntax, and adherence to naming
conventions. You can also determine statistical information or search for certain
ABAP words (tokens). In the Code Inspector, you can define inspectionsthat, with
the help of check variants, examine certain sets of objects. As the result of an
inspection, you receive information messages, warning messages, or error
messages on different properties of the examined objects.
Limitations:
The range of functions in the Code Inspector is limited to checking static object
definitions and can therefore only point out certain problems.
It cannot, for example, give a precise statement as to how the overall performance
of a program is. To be able to do this, you need to analyze program execution
yourself at runtime for example, using the Runtime Analysis Tool (transaction code
SE30), the Performance Trace (ST05), or the Global Performance Analysis Function
(ST30).
Page 56 of 74
Inspection
2.
Object Set
3.
Check Variant
What is Inspection?
Inspection is the process of checking individual objects or set of objects as to
whether certain programming guidelines have been adhered to. The result of an
inspection run is a list of the individual checks made with errors, warnings, or
information messages. There are two types of inspections. They differ with respect
to whether the results are made persistent or not.
Persistent
inspections
with
results
storage
For execution on the local server or parallel execution on the server group. You can
plan persistent inspections as background jobs and use them for any size of object
set.
Anonymous
or
ad-hoc
inspections
without
results
storage
For execution on the local server and for fewer than 50 objects. You can execute adhoc inspections in online mode only.
Page 57 of 74
When you give a name in inspection box and click create icon following is the
screen you get.
In the screen above you can see we can do inspection of an Object set (we will see
shortly what that mean) which can be thought of as a collection of objects, Or we
can do inspection of objects captured under any transport request by selecting the
Request/Task radio button.
We can also do inspection of individual objects by selecting the Single radio button
and giving the type of object and giving the name in the input box.
The next thing is Check Variant which is kind of collection of check rules that we
have to follow while inspecting any object.
What are Object Sets?
They are collection of several single objects together in a group/set. Sets of objects
include, for example, programs, function groups, classes, or DDIC objects. In
general, any Repository objects can be included in a set of objects.
There are global and local sets of objects.Global sets of objects are visible for all
users while local objects are only visible for a single user. You can create global sets
of objects only if you have the appropriate authorizations.
Page 58 of 74
Below is the screen you will get when you give the Object Set name and click the
create icon.
There are lots of filters that you can use to group objects into an object set.
Page 59 of 74
SAP supplies the global DEFAULT variant, which you can use to check objects from
within the workbench i.e. when you do from SE24, SE37, SE38 or SE80. You can
anytime enhance the predefined list of check categories and individual checks
supplied by SAP but with restriction that you have proper authorizations to change
or create check variants.
The individual checks are assigned to different check categories. The following list
shows examples of check categories and individual checks.
General checks contain formatting elements, such as listing table names from
SELECT statements.
Performance checks contain checks for performance and for resource use,
such as:
1.
2.
3.
Page 60 of 74
If we select the check box for a category all sub items will be checked, you can
manually select multiple items from the tree structure and enable the checks.
There is an arrow shown in attributes column where you can again do a pinpoint
check. Clicking on the attributes arrow will open more options to be checked.
Page 61 of 74
For every check there is documentation provided where you can see how this check
will work and what results you can expect after the inspection.
So go and dig down into the options provided and do not just rely on the results of
Workbench Code checks. Create a custom check variant where it will check for all
the possible errors that one can expect to be rectified in static review of the code.
*************************************************************************************
*************
Evaluating the Quality of Your ABAP with Code Inspector Part 2
by admin on June 15th, 2014
Page 62 of 74
This blog will focus on the code inspector prior to EhP2 for SAP NetWeaver 7.0
support package stack 12 (SAP Basis 7.02, SAP Kernel 7.20) and EhP3 for SAP NetWeaver 7.0
support package stack 5 (SAP Basis 7.31, SAP Kernel 7.20). The reason I bring this to your
attention is because after the above, we now have a NEW solution for quality management
called the ABAP TEST COCKPIT. The ABAP Test Cockpit is a new ABAP check toolset which
allows you to run static checks and unit tests for your ABAP programs. In order to ensure a
smooth migration and comparable check results throughout your company, the ABAP Test
Cockpit is compatible with SAPs Code Inspector. This means you can reuse your custom Code
Inspector checks and variants in the ABAP Test Cockpit.
Back to our Blog..
When you are working on a program, function module, or class, you typically call the ABAP
Syntax Check directly from the editor iteratively as we code. But wouldnt it also be nice to
have the performance or security checks of the Code Inspector at your disposal while coding?
As of Web AS 6.10, you can call the Code Inspector for the object you are working on from the
menu of the ABAP Workbench (SE80), the ABAP Editor (SE38), the Function Builder (SE37), or
the Class Builder (SE24). When called from these workbench transactions, the Code Inspector
automatically applies the DEFAULT check variant to the examined objects and the inspection
results are not persisted.
Select <Object>=>Check =>Code Inspector where <Object> represents aProgram, Function
module, or Class.
Page 63 of 74
Page 64 of 74
3) In the Object Assignment area of the Select Object Set tab, enter the SAP user name
HA92974 in the Person responsible field not to be confused with the Person
Page 65 of 74
Responsible field at the top of the screen, which is the name of the person responsible for the
object set itself which is E71800017 in the screen below.
4) In the Object Selection area in the lower area of the screen, enter an asterisk (*) in the
Class/Interface field. The asterisk ensures that all classes assigned to the user HA92974 will
be included. If you enter ZCL_SV* instead, only classes that start with ZCL_SV are selected.
5) Save the object set by clicking the Save button in the standard toolbar.
Once you have created and saved an object set, you can then tailor your object selections
further. For instance in the Object Assignment section you could use the additional Package,
or SAP Component options to include or exclude single packages or components. Note that
these options are linked by AND operations. Be careful NOT to choose entries that define a set
Page 66 of 74
without an intersection. For example, if I choose user HA92974 and SAP Component FIN and
this user has no objects in that component, then the resulting Object Set will be empty.
Creating an object set from scratch is typically the first method you learn. Once you become
familiar with using the Code Inspector, other methods of creating object sets offer added power
and flexibility. You access these additional methods via the following tabs on the object set
screen:
Edit Object Set: You can combine object sets and filter them based on the attributes Object
Type, Object Name, Package, and Responsible. Use this option when you want to create
an object set that consists of some combination of two other object sets.
Object Set from Result: You can create a new object set containing objects that triggered
messages in aprevious inspection. Again, you can filter the set based on the attributes Object
Type, Object Name, Package, and Responsible, and also by a single check, its message
codes, and message priority (Error, Warning, or Information). Use this option if you want to
determine your result set in several steps in other words, use any objects that raise issues in
a first inspection as the object set for a subsequent inspection.
Object Set from Request: You can also extract object sets from transport requests/tasks and
filter them based on the attributes Object Type, Object Name, Package, and Responsible.
If there are program like objects in the request, the new object set will contain only their
associated main programs (programs, classes, or function groups instead of includes, methods,
or function modules). Use this option when you want to check the objects in a transport request.
For example, you might want to ensure that only objects adhering to your security rules are
transported into your production system.
Obj. Collectors: You can use generic collectors to create an object set. You can do this by
loading the objects from files or from object lists of programs, such as Where-Used List,
Coverage Analyzer, or Runtime Analysis. Then in the Set Filter screen area you can filter them.
WARNING A daily background job prevents the Code Inspector from accumulating too much
data. Inspections and object sets have an automatically generated deletion date of 50 days
ahead, which means that the inspection or object set will be deleted after 50 days. Inspections
that have not yet been executed, as well as object sets included in those inspections, are
Page 67 of 74
excluded. To keep your object sets or inspections for a longer time, simply change the deletion
date. You can change the deletion date individually for individual inspections and object sets.
Page 68 of 74
2) To add a check to your check variant, select the checkbox next to the check. To see
information about a check, click the Information button next to the checkbox.
3) Some checks require USER Parameters. You can see this by the
icon next to the check.
You can set one or more parameters to further define the check attributes. These attributes can
be input parameters or can activate a sub-check (a component of a single check that can
generate a message). Click the arrow to display a popup where you can set the parameters.
Page 69 of 74
4) To save the check variant, click the Save button on the standard toolbar.
Page 70 of 74
1) In the Code Inspector (transaction SCI), enter a name for the inspection and click the
Create button.
2) Combine an object set, a single object, or objects from a request with an existing check
variant.
Page 71 of 74
3) You can run the named inspection in one of two ways. You just click the execute
button
to start the inspection immediately or you can click the other execute button with 3
. after it
to display the Execution Options pop-up screen.Here you can further control
how and when the inspection is run. This includes selecting a server group for large object sets,
so they can be run in parallel across the app servers for performance. This would be done as a
Batch job and to schedule the inspection in a background job, click the In Background radio
button.
Page 72 of 74
Page 73 of 74
Each message contains the name of the examined object and a short explanation of why the
message was raised. If the examined object is a Report, Include, Function Module, Classetc.,
you also see the source code position of the statement that caused the message. Doubleclicking the message text takes you to the ABAP Workbench, where you can display and edit
the object. For further explanation, press the Information button next to the message.
You now have created and object set to be examined, the Check variant that has all the relevant
CODE checks you would like to employ and ran a NAMED inspection and examined the results.
Not bad for a days work!
The Code Inspector comes with a set of built-in checks that are organized into functional
categories. In the final installment of this Blog series I will you introduce you to the
most important checks in these categories To help you get the most out of the Code
Inspector right away!
Page 74 of 74