‎2008 Mar 28 6:17 AM
‎2008 Mar 28 6:20 AM
Global Classes and Interfaces
Classes and interfaces are both object types. You can define them either globally in the R/3 Repository or locally in an ABAP program. If you define classes and interfaces globally, they are stored in special ABAP programs called class pools (type K) or interface pools (type J), which serve as containers for the respective object types. Each class or interface pool contains the definition of a single class or interface. The programs are automatically generated by the Class Builder when you create a class or interface.
A class pool is comparable to a module pool or function group. It contains both declarative and executable ABAP statements, but cannot be started on its own. Instead, the system can only execute the statements in the class pool on request, that is, when the CREATE OBJECT statement occurs to create instances of the class.
Interface pools do not contain any executable statements. Instead, they are used as containers for interface definitions. When you implement an interface in a class, the interface definition is implicitly included in the class definition.
Class pools contain a definition part for type declarations, and the declaration and implementation parts of the class.
Differences From Other ABAP Programs
Class pools are different from other ABAP programs for the following reasons:
ABAP programs such as executable programs, module pools, or function modules, usually have a declaration part in which the global data for the program is defined. This data is visible in all of the processing blocks in the program. Class pools, on the other hand, have a definition part, in which you can define data and object types, but no data objects or field symbols. The types that you define in a class pool are only visible in the implementation part of the global class.
The only processing blocks that you can use are the declaration part and implementation part of the global class. The implementation part may only implement the methods declared in the global class. You cannot use any of the other ABAP processing blocks (dialog modules, event blocks, subroutines, function modules).
The processing blocks of class pools are not controlled by the ABAP runtime environment. No events occur, and you cannot call any dialog modules or procedures. Class pools serve exclusively for class programming. You can only access the data and functions of a class using its interface.
Since events and dialog modules are not permitted in classes, you cannot process screens in classes. You cannot program lists and selection screens in classes, since they cannot react to the appropriate events. It is intended to make screens available in classes. Instead of dialog modules, it will be possible to call methods of the class from the screen flow logic.
Local Classes in Class Pools
The classes and interfaces that you define in the definition part of a class pool are not visible externally. Within the class pool, they have a similar function to local classes and interfaces in other ABAP programs. Local classes can only be instantiated in the methods of the global class. Since subroutines are not allowed in class pools, local classes are the only possible modularization unit in global classes. Local classes have roughly the same function for global classes as subroutines in function groups, but with the significant exception that they are not visible externally.
Procedure to create a new interface
To create a new interface from the initial screen of the ABAP Workbench:
Enter the name of the interface, remembering to observe the naming convention
Select object type Interface.
Choose Create.
The Create Interface dialog box appears.
Enter the following information:
- Description
A short descriptive text for the new interface.
- Modeled only
No interface pool is generated for the marked interface. You therefore cannot access these interfaces at runtime.
In future, this option will allow you to design interfaces based on a graphical model.
Choose Save.
The Create Object Directory Entry dialog box appears.
Specify your Package.
Choose Save.
The method display of the Class Editor appears. From here, you can define the components of the interface. Only after you have defined the interface can you include it in class definitions.
Result
You have created a new interface along with its basic data in the ABAP Dictionary. The system generates an interface pool for the interface, as long as you did not create the interface as Modeled.
Plz reward if useful
Regards
Richa
Edited by: Richa Khosla on Mar 28, 2008 7:24 AM
Edited by: Richa Khosla on Mar 28, 2008 7:30 AM
‎2008 Mar 28 6:22 AM
Hi,
Interface pools do not contain any executable statements. Instead, they are used as containers for interface definitions. When you implement an interface in a class, the interface definition is implicitly included in the class definition
Reward if useful
regards
Ravi
‎2008 Mar 28 6:24 AM
hi,
Class and Interface Pools
Global Classes and Interfaces
Classes and interfaces are object types. You can define them either globally in the Repository or locally in an ABAP program. If you define classes and interfaces globally, special ABAP programs called class pools or interface pools of type K or J serve as containers for the respective classes and interfaces. Each class or interface pool contains the definition of a single class or interface. The programs are automatically generated by the Class Builder when you create a class or interface.
A class pool is comparable to a module pool or function group. It contains both declarative and executable ABAP statements, but cannot be started on its own. The runtime system can create runtime instances (objects) through a request using the CREATE OBJECT statement. These objects execute the statements of the class pool.
Interface pools do not contain any executable statements. Instead, they are used as containers for interface definitions. When you implement an interface in a class, the interface definition is implicitly included in the class definition.
The introductory program statements CLASS-POOL and INTERFACE-POOL are provided solely for class and interface definitions. A program introduced with the CLASS-POOLstatement can only contain global type definitions and definitions of classes and interfaces. Programs introduced with INTERFACE-POOL can only contain the definition of a global interface. The CLASS-POOL and INTERFACE-POOL statements must be generated solely by the Class Builder tool.
Hope this helps, Do reward
Edited by: Runal Singh on Mar 28, 2008 11:54 AM
‎2008 Mar 28 6:26 AM
Hi,
Firstly ,
It is like a super class.
It contains method definitions without implementations.
If we want to implement those methods, we have to inherit the interface to a class and then we have to implement those methods
Second,
In a class pool, you use the Class Builder tool of the ABAP Workbench to define
exactly one global class of the class library, which can then be used in all other
ABAP programs. In the global declaration section of a class pool, you can individually
define local data types, classes and interfaces to tbe used in the class pool and make
type groups known. Apart from the TYPES and TYPE-POOLS statements, in class pools no
other statements are allowed outside of classes and interfaces.
In an interface pool, you use the Class Builder tool of the ABAP Workbench to define
exactly one global interface of the class library to be used in all other ABAP programs.
In the global declaration section of an interface pool, you are not allowed to define
local data types, classes and interfaces. You can declare type groups. Apart from the
statement TYPE-POOLS, in interface pools no other statements are allowed outside of the
global interfaces.
In all other ABAP programs, except type groups, you can define local classes and interfaces
to be used in the program itself.
.
Reward points if useful
~Lakshmiraj~