These are stored centrally in the class library in the r/3 Repository.
Transaction code: SE24.
All of the ABAP programs in an R/3 System can access the global classes.
Local Class
Local Classes are defined within an ABAP program.
Local classes and interfaces can only be used in the program in which they are defined.
When you use a class in an ABAP program, the system first searches for a local class with a specified name. If it does not find one, it then looks for a global class.
Attributes: Attributes are variables, constants declared within a class.
Methods: Methods are coding blocks that provide some functionality.
Constructor and class_constructor: special types of methods. Constructor and class_constructor are automatically called when you create an object or when you first access the components of a class.
Events: Objects or classes can use events to trigger event handler methods in other objects or classes. In a normal method call, one method can be called by any number of users. When an event is triggered, any number of event handler methods can be called.
Types: We can define our own ABAP data types within a class using the TYPES statement. Types are not instance-specific and exist once only for all of the objects in a class.
Constants: Constants are special static attributes. We can set their values when we declare them, and they can then no longer be changed. We can declare constants using the CONSTANTS statement.
Visibility of Components of Class
Public
Protected.
Private.
Public section: Data declared in a public section can be accessed by the class itself, by its sub-classes as well as by other users outside the class.
Protected section: Data declared in the protected section can be accessed by the class itself, and also by its sub-classes but not by external users outside the class.
Private Section: Data declared in the private section can be accessed by the class only, but not by its sub-classes and by external users outside the class.
Instance and Static Components
Instance components :
These components exist separately in each instance (object) of the class and are referred to using instance component selector using ->.
A separate copy will create for each object.
Instance components can call static components.
Static components :
These components exist globally for a class and are referred to using static component selector =>.
If you change the value, then the original value will get affected.
No comments:
Post a Comment