Ansicht
Dokumentation

ABENSHEET_ABAP_OO_ABEXA - SHEET ABAP OO ABEXA

ABENSHEET_ABAP_OO_ABEXA - SHEET ABAP OO ABEXA

PERFORM Short Reference   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

ABAP Object Orientation

This example demonstrates various syntactical options and concepts related to ABAP object orientation as outlined in the ABAP cheat sheet ABAP Object Orientation.

Note that the demonstration classes and especially the method implementations are kept very simple in a minimalist approach to focus on how things basically work with ABAP object orientation - purposely renouncing the complexity of real world examples.

Source Code

Execute

Description

The output shows the outcome of various ways about how to work with ABAP object orientation concepts. Find comments in the output explaining the context and details. Basically, all variants described in the ABAP cheat sheet ABAP Object Orientation are covered and more:

  • Working with objects and components
  • Declaring reference variables, creating objects, assigning, overwriting, keeping and clearing object references, accessing and using attributes

  • Calling static and instance methods, various examples dealing with method parameters, constructors in use

  • Method redefinition in inheritance
  • Working with interfaces, interface references, upcast and downcast
  • Using factory methods in a singleton class and abstract class
  • Using events

The program includes multiple local classes and an interface for demonstration purposes. Almost all methods that are used in the examples are implemented in this program. The following classes and interface are included:

  • lcl_demo: Includes multiple method definitions and implementations to showcase method parameters like importing, exporting, changing, returning, raising and more. The purpose of most of the methods is to work with the values that are passed to and retrieved from the methods and to do simple calculations.
  • local_class: A very simple class that only includes some attributes and the definition and implementation of the instance constructor. Its purpose is to demonstrate the very basics as shown in the main class lcl_main.
  • lcl_events: Demonstrates the use of instance events.
  • lcl_constructors: Demonstrates the use of instance and static constructors.
  • lcl_class1, lcl_class2, lcl_class3: These very simple classes only contain one method each. They are used to demonstrate inheritance. The method included is used to show the redefinition of methods.
  • intf: Interface containing simple instance and static components.
  • lcl_singleton: Demonstrates a factory method in a singleton class.
  • lcl_abstract: Demonstrates a factory method in an abstract class.
  • lcl_friend: Demonstrates the concept of friendship.
  • lcl_main: Represents the main class for the program execution.





ABAP Short Reference   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.

Length: 3631 Date: 20240420 Time: 125314     sap01-206 ( 52 ms )