Académique Documents
Professionnel Documents
Culture Documents
used this tool, complete with screen the questions that this article will of the ABAP code. In addition, you
shots and “lessons learned”. What’s address: may also search through the code for
next? Assemble the troops and pre- single words and/or patterns of ABAP
pare for inspection. • What are the two methods for call- statements. The objects that may be
ing the Code Inspector? checked using the Code Inspector are
Introduction shown in Figure 1.
SAP has empowered consultants • What are the errors that the Code
(and users) in all areas by provid- Inspector may identify?
ing tools for checking the quality of Function Groups
their work. The ABAP Workbench • What are some of the code improve- Programs
is no exception. One such tool avail- ment hints the Inspector may sug- Classes
able with the ABAP Workbench is gest? Interfaces
the Code Inspector. It allows you to
Type Groups
check the syntax and semantic con- I will begin with an overview of
sistency of ABAP programs, and also the Code Inspector and the benefits it
lets you improve their performance. provides to developers. I’ll discuss, in Figure 1: Objects That May Be Checked
Green Information
• Constructs in which
authorization checks are
essential, but are not
used.
d) Search Functions
In addition to the checks
mentioned, the Code Inspec-
tor allows you to search for
words (tokens) or entire state-
ments in your Object Set. The
search option also allows you
to base your search on pat-
terns using wildcards such
as “+”and “*”. For searching
a word or statement in your
Object Set, create a Variant
that is comprised of one (or
both) of the search functions
(see Figure 11). The Inspec-
tion is then created and exe-
cuted as already mentioned.
There are two search func- Figure 11: Specifying a Search Function
tions available, namely token
search and statement search.
The token search function allows * represents any number of words. ation. For example, our READ state-
you to locate single words (having at For example, consider the statement ment pattern may look like:
least a length of three characters) in pattern:
your program code. When using this READ TABLE + WITH KEY +ABC+ =+
search option, the characters + and * READ TABLE + WITH KEY + = +
SAPtipsJournal
have special meanings. The symbol + For the key field, the system
represents a single character within a In this case, the system searches for searches only for those fields that are
word, whereas * denotes a sequence all READ statements that find a table five characters long and have “ABC”
of characters. For example, if you row, on the basis of a single key field. in the center.
want to search for internal tables In other words, after the KEY clause,
having names ITAB1, ITAB2, etc., you may expect a table field name, Suppressing Checks for
you will write ITAB+ in the search followed by an “=”symbol and then Selected Code Statements
field. a comparison value. All READ state- When an inspection is executed, all
ments that use two or more field com- the checks selected for the specified
On the other hand, the Search parisons are omitted by this search. Variant are carried out. However, in
ABAP Statement Patterns lets you some exceptional circumstances, you
find sets of similar ABAP statements You may combine the rule men- may need to exclude a given program
within your ABAP code. In this case, tioned in the token search with the from the code inspection. If you want
the + and *may also be used to define statement search function in order to to skip a check for a given statement,
the search criteria. While search- define more powerful search criteria. you need to insert special check-spe-
ing for a statement, the wildcard + In this case, additional information is cific phrases known as pseudo-com-
denotes one word or token, whereas provided for the token in consider- ments, in the program code. Exam-
ples are “#EC CI_NOWHERE and check, click on the icon on the Vari- Putting It All Together
“#EC CI_NOFIRST. This is inserted ant creation screen (see Figure 7). In this section, I will use the con-
at the end of the statement that is to This displays the documentation of cepts presented in this article to dem-
be skipped from the check. the given check that mentions the onstrate how the Code Inspector may
relevant pseudo-comment name, as be used to fulfill a simple require-
In order to find out which pseudo- shown in Figure 12. ment. Let us consider the following
comment is appropriate for a given scenario:
Conclusion
In this article, I discussed the
basics of the Code Inspector and
the steps required in order to test
the quality of ABAP programs.
Then, I listed the set of checks
and functions that the Inspec-
tor supports. Finally, I discussed
a requirement that may be ful-
filled via use of this tool. I hope
that this article will be a pre-
cious resource for you, and will
help you in checking the quality
of your programs in the least
possible time.
This documentation is delivered as is, and Klee Associates, Inc. makes no warranty as to its accuracy or use. Any use of this documentation is at the risk of the user.
Although we make every good faith effort to ensure accuracy, this document may include technical or other inaccuracies or typographical errors. Klee Associates,
Inc. reserves the right to make changes without prior notice. NO AFFILIATION: Klee Associates, Inc. and this publication are not affiliated with or endorsed by SAP
AG, SAP AG software referenced on this site is furnished under license agreements between SAP AG and its customers and can be used only within the terms of such
agreements. SAP AG and mySAP are registered trademarks of SAP AG. All other product names used herein are trademarks or registered trademarks of their
respective owners.
SAPtipsJournal