首页 > SAP > SAPUI5 > Create Local Class in OO ABAP
2019
08-27

Create Local Class in OO ABAP

In this tutorial, we will learn how to create a Local class in OO ABAP. In core ABAP, we modularize the ABAP code using function modules and subroutines. We can also modularize the same code in object oriented approach by creating local classes in the program. There are two parts involved while creating local classes, they are

Definition
Implementation

In Definition part we define all the attributes and methods with access specifiers(mandatory) and all DATA and TYPES declaration are defined in Definition section of the class.

We implement the methods i.e we write the abap code in the methods, in Implementation section of the class.

Definition

Implementation

[adsenseyu1]

As you are ready with Class Definition and Class Implementation, our next step would be how to call the attributes and methods which are defined in class. To access any components of the class first we need to instantiate the class (or) in other words we need to create object for the class(except for static components).

To create object for the class we use the below two lines of code.

To access the attributes and methods of local class

Now you know how create program and modularize the abap code using object oriented approach. Now pick up old program which are based on procedural paradigm and convert them into object oriented programs. Try to adopt the object oriented style in your future programs you develop.

最后编辑:
作者:yangsen
有需要可在文章留言或者邮件yan252@163.com给我。