OO ABAP – Interfaces and Polymorphism

Interfaces are simply superclasses that cannot be instantiated, do not have an implementation part, and only have public components.
This video will teach you how to define and implement interfaces to use polymorphism in ABAP.

Interfaces

  • The only real difference between interfaces and inheritance is the role they play. The programming advantages are thus the same as for inheritance.
  • Interfaces differ from regular inheritance in their area of use. In terms of programming, there are hardly any differences, however.
  • From a technical point of view, interfaces are simply superclasses that:
    • cannot be instantiated,
    • do not have an implementation part,
    • and only have public components
  • In ABAP Objects, interfaces primarily serve to define uniform interfaces for services.
  • Interfaces contain no implementations.
  • In ABAP Objects, the same components can generally be defined in interfaces and in classes.

Use of Interfaces

  • Some typical use cases of interfaces are:
    • You want to allow for the option of having multiple classes implementing a service in different
      ways, but using the same method names.

      • With regular inheritance, you would define such a method in the shared superclass. However, if you cannot model a superclass suitably for inheritance, you need to define an interface and then define this method there.
    • Classes implement interfaces as follows:
      • The interface name is listed in the definition part of the class with the INTERFACES statement. This must be in the PUBLIC SECTION, that is, interfaces can only be implemented publicly.
      • The interface methods must be implemented in the implementation part of the class.
      • The components defined in the interface can be addressed in the implementation part of the class.

Click here to download the presentation and source code for this video.

 

Preview – OO ABAP: Inheritance & Casting

Learn ABAP

Click here to download the source code and presentations for this video.

Inheritance is an implementation relationship that emphasizes similarities of the classes. In this video you will learn how to create class hierarchies using ABAP Objects.
After watching this video you will be able to:
1. Define inheritance relationships between classes
2. Redefine methods
3. Understand the basics of casting

Introduction to OO Concepts

  • Object oriented concepts are the basic programming techniques common to all object-oriented languages.
  • As far as these concepts are concerned, the only difference between ABAP Objects and other languages like Java or C++ is the syntax.
  • You can only capitalize on the strengths of object-oriented programming if you use all of the concepts in the intended manner.

Inheritance & Casting

What is Inheritance?

  • Different kinds of objects often have a certain amount in common with each other.
  • Cars, trucks, and buses, for example, all share the characteristics of vehicles (current speed, current gear).
  • Yet each also defines additional features that make them different:
    • For example, trucks carry cargo and have more tires than a car
    • Buses carry more passengers than trucks and cars.

Inheritance: is the concept that when a class is defined, any subclass that is defined can inherit the definitions of that class.

There is no multiple inheritance in ABAP Objects. However, you can use interfaces in ABAP Objects to simulate multiple inheritance.


Purchase a Premium Pass with an access link to watch the full video:
After completion of purchase , download the Premium Pass file where you will find the access link to the video.
You will also receive an email, shortly after the purchase, from Mendoza Learning Hub that will contain the Premium Pass and instructions for your video.


Or, become a Premium Member... - click here to become one

As a Premium member you get access to all of the videos, including this one. Log in to your Premium Account by clicking on 'Sign Up/Log In'. Visit your 'Member Profile' page where you will find access to all the Premium content. Alternately, you can visit the course's main page where you can access the premium videos.

If you didn't receive an email:
Check your spam folder. Many internet providers have spam filters that block emails that contain links. If you’re unable to find the confirmation email, then please contact us.

If you have problems with this video visit Help & Support, or contact us at info@carlosmdubon.com .


If you want a video on a particular topic, fill the form below.

[contact-form][contact-field label='Name' type='name' required='1'/][contact-field label='Email' type='email' required='1'/][contact-field label='Video Topic' type='text' required='1'/][contact-field label='Description' type='textarea' required='1'/][/contact-form]

OO (Object Oriented) ABAP – Introduction

 

This video is an introduction to the new ways of thinking and the related concepts of OO (Object Oriented) ABAP.

An example of encapsulating data using a function group is presented, and the advantage of using OO ABAP instead of procedural programming is demonstrated.

Introduction

  • Based on your existing knowledge of procedural programming with ABAP, I will explain the object-oriented approach using a Function Group.
  • I will illustrate one of the advantages of using object-oriented programming over procedural programming.
  • Let’s start by encapsulating data - a concept of the object-oriented programming mode – using a function group in ABAP.

Encapsulating Data: Speed

Function Group with functions to control the speed of a car.

FUNCTION-POOL zfg_vehicle.

*speed is a global variable

*used in the function-pool

DATA: speed TYPE i.

FUNCTION zfm_increase_speed.
ADD i_speed TO speed.

ENDFUNCTION.

FUNCTION zfm_decrease_speed.
SUBTRACT i_speed FROM speed.

ENDFUNCTION.

FUNCTION zfm_get_speed.
e_speed = speed.

ENDFUNCTION.

Video Lesson 2.1: SAP Object Navigator and Repository

Learn ABAP

Video Lesson 2.1: SAP Object Navigator and Repository

 

This lesson gives a short description of the Repository and a brief overview of
the most important components of the ABAP Workbench. It presents the Object
Navigator as a central development tool.

Introduction to the Repository

  • The Repository consists of all system development objects - programs, function modules, definitions of database tables, and so on.
  • In the Repository, you have objects delivered by SAP as well as objects defined by the customer.
  • The Repository is in the database
  • The Repository is subdivided according to application components. (Commonly known as ‘modules’)
  • Within a module (e.g., MM) there are several packages containing relevant objects for a more detailed logical subdivision.
  • Whenever a Repository object is created, it must be assigned to a package.

Working with the Object Navigator

  • The ABAP Workbench includes all tools required for creating and editing Repository objects.
  • These tools cover the entire software development cycle.

The most important tools are:

  • The ABAP Editor for editing source code
  • The ABAP Dictionary for editing database table definitions, central data types, and so on
  • The Screen Painter for configuring screens (screens together with functions for user dialogs)
  • The Menu Painter for designing user interfaces (menu bar, standard toolbar, application toolbar, function key settings)
  • The Function Builder for maintaining function modules
  • The Class Builder for maintaining global classes and interfaces