首页 > 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
本站为个人博客网站,全由我个人维护,我从事SAP开发13年,其它ERP开发7年,基本都是零售行业。本站记录工作学习的过程, 有SAP相关询问专、兼职工作可随时联系我。 有网站相关的问题可直接在文章下方留言,或者联系我。 邮件:yan252@163.com给我。 QQ:415402519