2 | Working with Objects
should be used to simplify the interface of the global class by removing an over-
abundance of private helper methods.
You can edit local classes by clicking on the IMPLEMENTATION button in the top-
level toolbar of the Class Editor. This will take you to an ABAP Editor screen
where you can create local classes using the same local class definition syntax
described earlier in this chapter.
2.4.5 Editing the Class Definition Section Directly
As stated previously, the Class Builder tool quietly generates ABAP Objects class
definition syntax behind the scenes as you edit global classes. You can access the
definition sections of
a
global class by selecting the menu options GOTO • PUBLIC
SECTION, GOTO • PROTECTED SECTION, and GOTO • PRIVATE SECTION, respectively, in
the Class Builder menu bar. For example, if you look closely at the ABAP Editor
screenshot shown in Figure 2.28, you will notice that the custom type TV_NAME is
being edited directly in the
PRIVATE SECTION
of the global class definition.
2.5 Case Study: Working with Regular Expressions
The demonstrative classes that we have reviewed thus far have been extremely
straightforward and uncomplicated. However, one of the beauties of object-ori-
ented programming is the fact that you can encapsulate complex logic inside of a
class that can be used by programmers who may or may not understand how it
works.
SAP provides many useful global classes in the standard distribution that can be
used right out of the box. An example of this is the regular expression API pro-
vided in classes
CL_ABAP_REGEX
and
CL_ABAP_MATCHER.
A regular expression is a
text string that is used to describe a search pattern in text. A regular expression
consists of literal characters and metacharacters. You can think of metacharacters
as a type of shorthand for describing certain character patterns — similar to the
use of the asterisk for representing one or more characters in a search help lookup
(see Figure 2.29). However, regular expressions are much more powerful, provid-
ing a more generalized syntax that can be used to express many different types of
complex text patterns.
82