Sunteți pe pagina 1din 43

Fundamentals of OOPS Programming

-1-

Objectives
Recognize the concept of Object Oriented Programming (OOP)
Identify the features of Object Oriented Programming
Analyze the basic building blocks of ABAP Objects
Inheritance
Events
Define Global class
Persistent Class
Exception Class

-2-

What is Object Oriented Programming (OOP) ?


The fundamental idea behind Object Oriented Programming (OOP) is to combine both
data and the functions (methods) those operate on that data into a single unit. Such an
unit is called Object.

-3-

Features of Object Oriented Programming


Class
Class is a prototype that defines data and methods.

Objects
Objects are instances of the class.

Ecapsulation
Hiding data and its related logic behind well defined interfaces.

Inheritance
Reusing attributes and methods while allowing for specialization.

Polymorphism
Simplifying by hiding varying implementations behind the same interface.

-4-

History of ABAP Object Oriented Programming


SAP Basis Release 4.5 delivered the first version of ABAP Objects.
SAP Basis Release 4.6 delivered complete version of ABAP Objects by introducing
Inheritance.

-5-

Classes (Global + Local)


Classes can be of two types:
Global Class (Created using class builder (SE24) and stored in class repository
as Class pool) are repository objects and accessible to any ABAP program
Local Class (Created in any ABAP program) are accessible only with in the
program where it is defined

Global vs. Local Global Classes


Classes

Local Classes

Accessed from ?

Any Program

Only with in the Program where it


is defined

Where store ?

In the class repository

In the program where it is defined

Tools required to
create ?

Class builder (SE24)

With ABAP editor (SE38)

Namespace ?

Must begin with Y or Z

Any

-6-

Declaring a Local Class


A class declaration has two parts.
Definition
Implementation
CLASS test DEFINITION.
PUBLIC SECTION.
{ Attributes, Methods, Events }
PROTECTED SECTION.
{ Attributes, Methods, Events }
PRIVATE SECTION.
{ Attributes, Methods, Events }
ENDCLASS.
CLASS test IMPLEMENTATION.
<class body>
{Method implementation is done here}
ENDCLASS.
----------------Example------------------------------------CLASS test DEFINITION.
PUBLIC SECTION.
DATA: int TYPE I VALUE 100.
METHODS display_int.
ENDCLASS.

This declares and defines a local class test .


In ABAP program, class DEFINITION belongs
to Global Section.
The class IMPLEMENTATION processing
block need not be at the top of the program.
Class definition cannot be nested.
Classes cannot be defined inside subroutines
or function modules.
A class definition declares :
Its components :
Attributes, Methods, Events.
The visibility of its components :
Public, Protected and Private.

CLASS test IMPLEMENTATION.


METHOD display_int.
WRITE / int.
ENDMETHOD.
ENDCLASS.
-7-

Components of Class ( Instance + Static )


Instance components:
DATA

Instance components exist separately in


each instance (object) of the class.

For instance attributes

METHODS
For instance methods

EVENTS
For instance events

Static components:
CLASS-DATA
For static attributes

CLASS-METHODS
For static methods

CLASS-EVENTS
For static events

Static components only exist one per class


and are valid for all instances of the class.
Static components are declared with the
CLASS- * keywords.
To access instance components, instance
component selector (->) is used.
To access static components, static
component selector (=>) is used.

-8-

Visibility of Components
All components of a class must belong to a visibility section. Components can be
public, protected or private.
Public components form the external interface of the class they are visible to all
users of the class as well as to methods within the class and to methods of
subclasses.
Protected components form the interface of the class to its subclasses they are
visible to methods of the heirs of the class as well as to methods within the class.
Private components can only be used in the methods of the class itself.

-9-

Methods
ABAP codes are written within a method to
incorporate the functionality.

CLASS test DEFINITION.


PUBLIC SECTION.
METHODS: do_something
IMPORTING ...i1 TYPE
EXPORTINGe1 TYPE
CHANGING c1 TYPE
EXCEPTIONS en.

Methods are processing blocks with a


parameter interface very similar to function
modules.
Methods are of two types:
Standard Methods.

PRIVATE SECTION.
DATA:

e.g. METHODS meth.

Event handler methods:

ENDCLASS.

METHODS meth FOR EVENT evt


OF class.
This type of methods are written to
trap events.

CLASS test IMPLEMENTATION.


METHOD do_something.

ENDMETHOD.
ENDCLASS.

Methods are called with a CALL METHOD


statement.

- 10 -

Objects and Object references


CLASS test DEFINITION.
PUBLIC SECTION.
DATA: int TYPE I VALUE 100.
METHODS display_int.
ENDCLASS.

Reference variables (TYPE REF TO)


contain references to objects- Users can
only access instance objects through
reference variables.
To use objects:
Declare reference variables.
Create objects, assigning their
references.

CLASS test IMPLEMENTATION.


METHOD display_int.
WRITE / int.
ENDMETHOD.
ENDCLASS.
DATA : oref TYPE REF TO test.
START-OF-SELECTION.
CREATE OBJECT oref.
WRITE / oref-> int.
CALL METHOD oref-> display_int.

- 11 -

Multiple instantiation
CLASS test DEFINITION.
PUBLIC SECTION.
METHODS meth.
ENDCLASS.

Programs can instantiate multiple


objects of the same class.

CLASS test IMPLEMENTATION.

ENDCLASS.
DATA: oref1 TYPE REF TO test,
oref2 TYPE REF TO test.
START-OF-SELECTION.
CREATE OBJECT oref1, oref2.

- 12 -

Pointer tables
DATA: oref1 TYPE REF TO test,
oref2 TYPE REF TO test,
oref3 TYPE REF TO test.
DATA: oref TYPE REF TO test,
oref_tab TYPE TABLE OF REF TO test.
START-OF-SELECTION.

Pointer tables are used to store


multiple instances of same class.
This method reduces coding and
more elegant against creating
separate, separate object reference
variables for storing every objects of
the same class.
Reference variables are handled
like any other data object with an
elementary data type.

DO 3 TIMES.
CREATE OBJECT oref.
APPEND oref TO oref_tab.
ENDDO.
LOOP AT oref_tab INTO oref.
CALL METHOD oref->meth.
ENDLOOP.

- 13 -

Constructors
METHODS constructor

Each class has one constructor.

IMPORTING

It is a predefined, public instance method


of the class, with the name
CONSTRUCTOR (or
CLASS_CONSTRUCTOR for static
constructor).

Instance constructor
CLASS Test DEFINITION.
PUBLIC SECTION.
METHODS: constructor IMPORTING A TYPE I.
PRIVATE SECTION.
DATA: fld TYPE STRING.
ENDCLASS.

Constructors are special methods that


produce a defined initial state of objects
and classes.
Constructors are executed once for each
instance. They are called automatically
after you have created an instance of the
class with the CREATE OBJECT
statement.

CLASS Test IMPLEMENTATION.


METHODS constructor.
WRITE A.
ENDMETHOD.
ENDCLASS.
CREATE OBJECT obj EXPORTING A = 10.

Static ConstructorCLASS-METHOD class_constructor


- 14 -

Inheritance Topics
Concept
Syntax and Visibility
Object References in Inheritance
Method Redefinition
Abstract Classes and Methods
Final Classes and Methods
Constructor in Inheritance
Polymorphism through Inheritance

- 15 -

Inheritance - Concept
The concept of inheritance is used to incorporate the properties of an existing
class into a new class. The beauty of this feature is that the methods and the
attribute of the existing class need not to be coded into the new class, as well as
new features can be added into the new class.
Inheritance can be single inheritance ( subclass is inherited from a single super
class) or multiple inheritance (subclass is inherited from multiple super classes).
But ABAP Objects supports only single inheritance.

Parent

Parent

Grand Parent
Parent

Child
Multiple Inheritance not
supported by ABAP Objects

Child

- 16 -

Single Inheritance supported


by ABAP Objects

Inheritance - Syntax and Visibility


CLASS super_class_a DEFINITION.
PUBLIC SECTION.
Public components_a
PROTECTED SECTION.

The public and protected components of


the super class are visible in the subclass.

Protected components_a
PRIVATE SECTION.
Private components

Private section of the super class is not


visible in the sub classes.

ENDCLASS.
CLASS sub_class_b DEFINITION INHERITING FROM
super_class_a.
PUBLIC SECTION.

Private components of the sub class can


have same name as the private component
of the super class.

Public components_b
Public components (super_class_a)
PROTECTED SECTION.
Protected components_b
Protected components (super_class_a)

Public and Protected components of the


sub class can not have the same name as
that have been used in super class.

PRIVATE SECTION.
Private section
ENDCLASS.

- 17 -

Inheritance - Object References


Object
Class Test1
Pub: a1, a2
Prot: b1, b2
Priv:c1,c2

Class Test2 Inheriting from Test1


Pub: a1, a2,a3,a4
Prot: b1,b2,b3,b4
Priv: c3,c4

Class Test3 Inheriting from Test2


Pub: a1, a2,a3,a4,a5,a6
Prot: b1, b2,b3,b4,b5,b6
Priv:c5,c6

DATA oref TYPE REF TO Test1.


CREATE OBJECT oref.

DATA oref TYPE REF TO Test2.


CREATE OBJECT oref.
DATA : oref1 TYPE REF TO Test1,
oref3 TYPE REF TO Test3.
CREATE OBJECT oref3.
oref1 = oref3. -> Perfect
oref1 ->a1.
-> OK
oref1 ->a5.
-> Error
DATA oref TYPE REF TO Test3.
CREATE OBJECT oref.
- 18 -

Inheritance - Method Redefinition


CLASS base_class DEFINITION.
PUBLIC SECTION.
METHODS: meth.
........
ENDCLASS.
CLASS derived_class DEFINITION INHERITING
FROM base_class .

A method can be re-implemented in


the derived class using redefinition
key word.
The parameters remain same in the
derived class as it was in base class.

PUBLIC SECTION.
METHODS: meth REDEFINITION.
. .. . . . . . . .
ENDCLASS.
CLASS derived_class IMPLEMENTATION .
METHODS meth.
CALL METHOD SUPER->meth.

ENDMETHOD.
ENDCLASS.

Redefining the base class method in the


derived class
Calling the super class method using
SUPER keyword
- 19 -

Inheritance - Abstract classes and methods


A class defined as ABSTRACT cannot be
instantiated , that is one cannot use
CREATE OBJECT with reference to the
class.

Abstract method
CLASS cl_super DEFINITION.
PUBLIC SECTION.
METHODS: demo1 ABSTRACT,

Abstract class serves as a template for


subclasses

demo2.
ENDCLASS.
Redefining the Abstract method of Super class
in the Sub class

If a class contains any abstract method the


whole class becomes abstract.

CLASS cl_sub DEFINITION INHERITING


FROM cl_super.

A method, which is abstract, should be


redefined in derived class.

PUBLIC SECTION.
METHODS demo1 REDEFINITION.
ENDCLASS.

- 20 -

Inheritance - Final classes and methods


CLASS final_class DEFINITION FINAL.
........

A final class can not be inherited further.

ENDCLASS.
CLASS derived_class DEFINITION INHERITING
FROM final_class .

A final method can not be redefined


further.

. .. . . . . . . .
ENDCLASS.
CLASS super_class DEFINITION .
........
METHODS final_method
final_methodFINAL.
FINAL.
ENDCLASS.
CLASS sub_class DEFINITION INHERITING
FROM super_class .
. .. . . . . . . .
METHODS final_method
final_methodredefinition.
redefinition.
ENDCLASS.

- 21 -

Inheritance - Constructors
CLASS base_class DEFINITION.
PUBLIC SECTION.
* Super class constructor
METHODS: constructor IMPORTING arg1 TYPE
STRING.
PRIVATE SECTION.
DATA: fld TYPE STRING.
ENDCLASS.
CLASS derived_class DEFINITION INHERITING
FROM base_class .
PUBLIC SECTION.
* Sub class constructor
METHODS: constructor IMPORTING arg1 TYPE
STRING
arg2 TYPE
STRING.
PRIVATE SECTION.
DATA: fld TYPE STRING.
ENDCLASS.
CLASS derived_class IMPLEMENTATION .
METHODS constructor.
* Calling super class constructor
CALL METHOD SUPER->constructor
EXPORTING arg1 = arg1.
fld = arg2 .
ENDMETHOD.
ENDCLASS.

- 22 -

As all public and protected components,


subclass inherits the constructor method
if it is present in the inheritance tree.

If an object of subclass is created at this


time the inherited instance attributes
and private attributes of the super
classes must also be initialized.

As the private attributes of the super


class is not visible to subclass, subclass
cannot fully initialize its super class.
Therefore to ensure complete
initialization of subclass and its super
classes, constructor is redefined.

Inheritance - Polymorphism
CLASS super_class DEFINITION.
..........
METHODS test_method.
ENDCLASS.
CLASS sub_class_one DEFINITION INHERITING
FROM super_class.
.........
METHODS test_method REDEFINTION.
ENDCLASS.
CLASS sub_class_two DEFINITION INHERITING
FROM super_class.
.........
METHODS test_method REDEFINTION.
ENDCLASS.
DATA: supr_obj type ref to super_class,
sub1_obj type ref to sub_class_one,
sub2_obj type ref to sub_class_two.
START-OF-SELECTION.
CREATE OBJECT sub1_obj.
CREATE OBJECT sub2_obj.
supr_obj = sub1_obj.
CALL METHOD supr_obj->test_method.
supr_obj = sub2_obj.
CALL METHOD supr_obj->test_method.

Reference variables declared with static


reference to a super class can dynamically
point to an object of a subclass of this super
class and access the components known to
the super class. Methods inherited from super
class may be redefined in one or more of the
subclasses. This is the basis of polymorphism
using inheritance.
Polymorphism here means using the same
name via same interface to address differently
implemented methods, belonging to different
objects of different classes in the inheritance
tree.

- 23 -

Interfaces - Concepts
Interface is similar to abstract class.
It has only definitions part.
The interface can be implemented only in the class that uses it.
Interface, which is an independent structure, is used to implement in a class to
extend the scope of a class.

- 24 -

Interfaces - Defining Interfaces


INTERFACE TEST1
DATA:
CLASS-DATA:
METHODS:
CLASS-METHODS:
EVENTS:
CLASS-EVENTS:
ENDINTERFACE
INTERFACE MY_INTERFACE.
DATA : name(20).
METHODS: I_method1,
I_method2.
ENDINTERFACE.

Interfaces are defines as independent


construct, in an INTERFACE.
ENDINTERFACE block similar to the
declaration block of classes.
An interface can declare instance as well
as static components like classes.
Interface components are always PUBLIC,
so visibility is not explicitly defined.
Interface define the methods but do not
Implement them. Similarly how sub
classes implement the methods of an
abstract class, all classes that wish to use
an interface must implement all of its
methods.

- 25 -

Interfaces - Implementing Interface in Classes


INTERFACE My_interface .
METHODS My_interface_method.
ENDINTERFACE.

CLASS interface_class DEFINITION.


PUBLIC SECTION.
INTERFACES My_interface.
ENDCLASS.

CLASS interface_class
IMPLEMENTATION.
METHOD
My_interface~my_interface_metho
d.
DATA: num TYPE I VALUE 10.
Write:/ num.
ENDMETHOD.
ENDCLASS.

An interface cannot be implemented without a


class.
Interface do not have instances.
Interface can be implemented in a class using
the statement INTERFACES <interface_name>
in the public section of a class.
The component of the interface are added
automatically in the public section of the class.
Each class can implement one or more
interfaces.
The class must implement all the methods of
each incorporated interface.
Multiple classes can implement the same
interface.
With in the class each component of the
interface is identified by the name intf~comp. ~
is called interface component selector.
- 26 -

Events - Defining and triggering Events


CLASS test_event_class DEFINITION.
PUBLIC SECTION.

Events can be delcared as PUBLIC,


PROTECTED, PRIVATE components of
any class or interface.

* Event declaration
EVENTS
My_event_click.
METHODS : event_raising_method.
ENDCLASS.

Events can be static or instance

CLASS test_event_class IMPLEMENTATION.

Events can be triggered by any method in


the class using the RAISE EVENT
statement.

METHOD event_raising_method.
*
Triggering the event
RAISE EVENT My_event_click.
ENDMETHOD.

Events dont have implementation part.

ENDCLASS.

- 27 -

Handling Events
CLASS test DEFINITION.
PUBLIC SECTION.
* Declaration for event handler method
METHODS: event_method_click
FOR EVENT My_event_click
OF
test_event_class.

Any class can define event handler


methods for the events of the class itself
or for those of other classes.
Event handler methods use the FOR
EVENT (event name) OF {CLASS (class
name) | INTERFACE (interface name)}
addition.

ENDCLASS.
CLASS test IMPLEMENTATION.
METHOD event_method_click.
..
ENDMETHOD.
ENDCLASS.

Methods are only executed when the


event associated with these methods are
triggered.

- 28 -

Registering events
START-OF-SELECTION.
DATA: object1 TYPE REF TO test,
object2 TYPE REF TO
test_event_class.
CREATE OBJECT: object1,
object2.

To automatically execute the event


handler method when the event is
raised, the handler method has to be
registered.

The registration process is dynamic i.e.


the link is established at runtime. The
key statement SET HANDLER can
register the handler method.

Registering the event handler method


SET HANDLER object1>event_method_click
FOR object2.
Calling the triggering method
CALL METHOD :
object2-> event_raising_method.

- 29 -

Global classes and interfaces : Concept


Global classes and interfaces are created and stored in class pool and interface
pool like function pool (function group).
Global classes and interfaces are managed centrally and available to every
program.
Custom Global classes and interfaces must begin with Y* or Z*.
Global and local classes and interfaces have the same components, and there is
no difference in how they are used within programs.
Global classes and interfaces are maintained via transaction SE24 or SE80.
Use Class Browser to view global classes and interfaces in the repository.

- 30 -

Creating Global class


1. Go to transaction SE24 and
enter the name of your custom
class or interface (name must
start with Z* or Y*) and press
create button.

3. In the next popup enter description


and press SAVE button. (Also check
Usual ABAP class radio button is set
and Final check box is checked.)

2. Choose the Object type.


Here Class is selected as object
type.

4. In the next popup enter package


name and press save button

- 31 -

Creating Global class (Contd.)


5. Now double click on the class, it
will then display the class builder,
define attributes and methods
for the class.

6. Double click on the method


name to implement the
method. It will invoke the code
editor where you have to enter
code for the method.
7. Activate the class.
8. Test the class.

- 32 -

Creating a global class from a local class


1. First define a local class in Program
Report ZCLASS_TEST3
CLASS zcl_test DEFINITION.
PUBLIC SECTION.
METHODS display
ENDCLASS.

4. Following pop-up appears, Enter your Z program


in which the local class is defined & press
ENTER

CLASS zcl_test IMPLEMENTATION.


METHOD display.
WRITE : Creating a global class from a local class.
ENDMETHOD.
ENDCLASS.

2. Now go to T-code SE24

3. Now select menu Object type -> import ->


Local classes in program (As shown
below):

5. The class name defined in our program is


ZCL_TEST and the proposed global class
name is CL_ZCL_TEST. Now you can rename
the global class name as per your
requirement.
If the local class is defined inside an include,
we need to check the checkbox Explode
INCLUDEs shown in step 4.

- 33 -

Create Transaction for local class method


1. First define a local class in Program
Report ZDEMO_OOP_IG
CLASS create_report DEFINITION.
PUBLIC SECTION.
METHODS Main.
ENDCLASS.

3. Now give a description and choose the


proper radio button.

CLASS create_report IMPLEMENTATION.


METHOD Main.
WRITE : Creating a global class from a local class.
ENDMETHOD.
ENDCLASS.

2. Now go to T-code SE93 & create a


4. Now enter report name (where the local class is
transaction for the method MAIN as
defined), local class name and method name.
shown in the screen shots below:
Give a Tcode name & press create button

- 34 -

Persistent Class - Concepts


Persistent Class

Persistence Services

The term persistent class does not imply


that a class is persistent. Instead, the
objects of that class are managed by the
Persistence Service.

There are no persistent objects in ABAP


Objects. However, the Persistence Service
allows the developers to work with persistent
objects.

When the Class Builder creates a


persistent class, it automatically generates
an associated class, known as the class
actor or class agent, whose methods
manage the objects of persistent classes.

The Persistence Service can be thought of as


a software layer between the ABAP program
and the database which allows you to save the
attributes of objects with a unique identity.

Creation of Persistent classes depends on


the existing database tables in the ABAP
Dictionary

Objects of these classes are instantiated in


the ABAP program with a method of the
Persistence Service, not with the usual
CREATE OBJECT statement. These objects
are known as managed objects.

- 35 -

Creating a Persistent class


When you create the class ZCL_TEST_PERSIST as a persistent class using the Class Builder,
new persistent class implements all the methods of interface IF_OS_STATE.
Class Builder automatically creates two further classes ZCA_TEST_PERSIST &
ZCB_TEST_PERSIST with the new persistent class. They are assigned to a separate class pool.
Class ZCA_TEST_PERSIST is known as class actor or class agent which is used to managed the
object of persistent class ZCL_TEST_PERSIST. This class inherits its method from the abstract
superclass ZCB_TEST_PERSIST. The programmer can extend the class actor and redefine its
methods (in particular, those for accessing the database).
Class ZCB_TEST_PERSIST is a subclass of a general superclass CL_OS_CA_COMMON. You
cannot change the class ZCB_TEST_PERSIST.
Attribute of the Class Actor : The class actor has a public static attribute AGENT. When you first
access this attribute in an ABAP program, the static constructor of the class CA_persistent
generates exactly one instance of this class.

- 36 -

Methods of Persistent Class


Most Important Methods of the Class Actor : The Class Builder generates the following
methods when you create the persistent class. You can then redefine them in the class
CA_persistent. These Methods are Inherited from the class CB_persistent
1) GET_PERSISTENT Reads a persistent object from the database. If an object with the same
key already exists in the database, it is not loaded again; instead, the system returns the
reference to the object already loaded.
2) CREATE_PERSISTENT - Create a new persistent object in the database. When the
Persistence Service creates the object, it does not check whether it already exists in the
database. An error occurs only when you try to save an existing object using COMMIT WORK. If
you are unsure, you should check whether the object already exists using the
GET_PERSISTENT method.
3) DELETE_PERSISTENT - Deletes a Persistent Object after COMMIT WORK statement. To
understand above methods, we can refer the Report program DEMO_CREATE_PERSISTENT

- 37 -

Exception Class - Concepts


Exceptions are represented by objects that are instances of exception classes. Defining an
exception is, therefore, the same as creating an exception class.
All exception classes must inherit from the common superclass CX_ROOT and one of its
subordinate classes: CX_STATIC_CHECK, CX_DYNAMIC_CHECK & CX_NO_CHECK
Class-based exceptions are either raised by the ABAP statement RAISE EXCEPTION or by the
ABAP runtime environment. If a class-based exception occurs, the system interrupts the normal
program flow and tries to find a suitable handler. If it does not find a handler, a runtime error
occurs.
A class-based exception can be handled in a TRY control structure. The TRY block defines a
protected area, whose exceptions can be handled in subsequent CATCH blocks.
DATA: l_oref
TYPE REF TO cx_root.
TRY.
MODIFY MARA FROM WA WHERE MATNR = ABC.
CATCH cx_sy_open_sql_db INTO l_oref.
lv_str = l_oref->get_text( ).
ENDTRY.
Custom exception classes must be start with the prefix ZCX or YCX

- 38 -

Creation of Exception Classes


Step1. Go to Transaction SE24, enter class
name as ZCX_EXCEP_CLS and Press create
button
For all exception classes CX will be the prefix.

Step3. Exception classes inherit the following


methods from base class CX_ROOT

Step2. In below Popup, Enter the super class


name CX_STATIC_CHECK.
Instead of creating new texts, you can use the
texts from an existing message class (which are
defined in TCODE SE91). Then select the With
Message Class checkbox. Press save button.

Step4. In Exception Class ZCX_EXCEP_CLS,


create attributes MSGV1, MSGV2, MSGV3, and
MSGV4 under attributes tab of the class builder.

- 39 -

Creation of Exception Classes Contd.


Step5. Choose Texts tab - To Insert Exception
Texts from Message Classes

Then Place the cursor on the default Exception


ID ZCX_EXCEP_CLS and then click on button
Message Text
Step6. A popup will be displayed. Enter Message
Class ZMM and Message Number 001.

Step7. Calling Exception Class inside the


program to handle exceptions

If you want parameterized Exception Texts,


assign the attributes (MSGV1, MSGV2 and
MSGV3) of an Exception Class to the
placeholders
[Placeholders (&) created here can be
dynamically be populated when runtime
exceptions are created using ABAP values via
exception class attributes. ]
Click on button
- 40 -

DATA: lo_ex_ref TYPE REF TO cx_root.


DATA: lv_message_text TYPE string.
TRY.
RAISE EXCEPTION TYPE ZCX_EXCEP_CLS
EXPORTING msgv1 = 'For'
msgv2 = 'Handling'
msgv3 = 'Exceptions .
CATCH zcx_excep_cls INTO lo_ex_ref.
lv_message_text = lo_ex_ref->get_text( ).
WRITE lv_message_text.
ENDTRY.

Name of some standard Exception Classes

- 41 -

Extensive use of ABAP Objects


SAP modules that uses ABAP Objects:

SAP GRC (Governance, Risk, and Compliance)


SAP CRM (Customer Relationship Management)
SAP SRM (Supplier Relationship Management)
SAP IS-H (Industry specific solution for Hospitalization
SAP cFolder
SAP EP (Enterprise Portal)
ABAP Web Dynpro

Examples of ABAP object:


Service classes such as CL_GUI_FRONTEND_SERVICES for working with data at presentation
server
Language related classes such as Run Time Type Services (RTTS) classes or
CL_ABAP_EXPIMP_UTILITIES subclasses for extended EXPORT/IMPORT functionality
Frameworks for persisting data in the databases (Object Services)

- 42 -

- 43 -

S-ar putea să vă placă și