Académique Documents
Professionnel Documents
Culture Documents
A class is a set of objects that have the same structure and the same
behavior.
We will start with a simple demonstration, lets create a class for our
previous function group example, we will call it ZCL_VEHICLE.
Private Public
Components Components
Speed Increase_speed
Private Access, Public Access,
generally: generally:
Attributes Methods
Data Types Attributes can be Decrease_speed Events
one of three types:
Elementary
Structured
Table Type Get_speed
TO CREATE AN ABAP CLASS,
Practical OPEN TRANSACTION CODE
SE24.
Example
Attributes: Visibility & Level
Visibility Level
Public Attributes:
Instance Attributes:
Generally Visible
Exist per instance
Generally changeable. Exception:
Defined with DATA
READ-ONLY addition.
Visibility Level
Public Methods: Instance Methods:
Can generally be called Access to static and instance
components is possible
Defined with METHODS
Private Methods:
Can only be called within the class
Static Methods:
Only access to static components is
possible
Defined with CLASS-METHODS
You can access public
attributes and methods from
Access to Static outside a class (e.g. from a
main program)
and Instance
Static attributes are
Elements accessed using:
classname=>static_attribute.
ATTRIBUTES AND METHODS
Instance attributes are
accessed with :
ref->instance_attribute.
Practical LETS CREATE A PROGRAM
THAT USES CLASS:
Example ZCL_VEHICLE