Book Image

Mastering SAP ABAP

By : Paweł Grześkowiak, Wojciech Ciesielski, Wojciech Ćwik
Book Image

Mastering SAP ABAP

By: Paweł Grześkowiak, Wojciech Ciesielski, Wojciech Ćwik

Overview of this book

Advanced Business Application Programming (ABAP) is an established and complex programming language in the IT industry. This book is designed to help you use the latest ABAP techniques and apply legacy constructions using practical examples. You'll start with a quick refresher on language and database concepts, followed by agile techniques for adding custom code to a modern ABAP system. After this, you will get up to speed with the complete ABAP toolset for importing data to and from different environments. Next, you'll learn how to print forms and work with the different ABAP tools for Extensible Markup Language (XML) manipulation. While covering further chapters, you'll gain insights into building stunning UI5 interfaces, in addition to learning how to develop simple apps using the Business Object Processing Framework (BOPF). You will also pick up the technique of handling exceptions and performing testing in ABAP. In the concluding chapters, you can look forward to grasping various techniques for optimizing the performance of programs using a variety of performance analysis tools. By the end of this book, you will have the expertise you need to confidently build maintainable programs in Systems, Applications, and Products (SAP).
Table of Contents (25 chapters)
Title Page
Copyright and Credits
Dedication
About Packt
Contributors
Preface
Index

Nested classes


In ABAP OOP, we can nest classes in three ways: 

  • A class as an attribute of the class
  • Inheritance
  • Using interfaces

Interfaces are not really a full class. This is due to the fact that, in interfaces, we have only a definition of a class without any implementation. This is important because interfaces in ABAP allow us to implement multi-inheritance. However, we'll turn to that in a moment, in the Inheritance and Interfaces section.

All examples will be shown as a global class created in SE24.

A class as an attribute of the class

We can create a class as an attribute of the class. To create that attribute, we need to add an attribute, which is typed as TYPE REF TO. In our example, we'll create an attribute as a reference to the ZCL_ENGINE class:

In the preceding example, we created an attribute named GR_ENGINE as an attribute of the ZCL_AUTO class. After the instantiation of ZCL_AUTO and the initialization of its GR_ENGINE attribute, a new object of the ZCL_ENGINE class is created inside...