Wednesday, August 17, 2016

Global Classes and Interfaces

Local and Global Classes

Classes in ABAP Objects can be declared either globally or locally. You define global classes and interfaces in the Class Builder (Transaction SE24) in the ABAP Workbench. They are stored centrally in class pools in the class library in the Repository. All ABAP programs have access to these global classes. 

Local classes are defined within an ABAP program. Local classes and interfaces can only be used in the program in which they are defined. When you use a class in an ABAP program, the system first searches for a local class with the specified name. If it does not find one, it then looks for a global class.

Global class are better suited for maintenance. Sometimes, your local classes need to be accessed from outside your component, report, ... and the question of conversion to global class arises.
For this, transaction SE24 provides the solution :
Object Type -> Import -> Local classes of in program

Nevertheless, ABAP Unit classes have to be embedded within objects to perform their tasks. Let's say you want to have a template for ABAP Unit class, you may want to maintain it as a global class. Thus, at some point in the process you will want to convert your global class into a local class.
Here it is (thanks BSP package !) :
PERFORM get_class_source IN PROGRAM bsp_export_classes
                         USING      'CL_GUI_FRONTEND_SERVICES'
                         CHANGING   lt_source. 


No comments:

Post a Comment

SAP giới thiệu mã hỗ trợ AI trong ngôn ngữ ABAP riêng của mình

SAP đã ra mắt một loạt tính năng mã hỗ trợ AI trong môi trường phát triển ứng dụng dựa trên đám mây của mình, đồng thời tham gia vào danh sá...