Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Forward Declaration in Class Builder

Former Member
0 Likes
2,113

Hi All,

In the Class Builder (SE24)when i create a new Class, There is an option of Forward declaration in the Property Tab. In this, we can add Type Group Interface and Class. What is the Purpose of this forward declaration?

The F1 help does not provide any help.

Regards,

Kapil.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,286

in addition to above replies, it can be used for classes and interfaces in that case Forward declaration is equivalent to

CLASS <class_name> DEFINITION LOAD. 

interface <interface_name> load

statements which are normally used in Program ( case for local classes )

use of Load from SAP docu

... LOAD

Effect

The variant with the LOAD addition loads a global class class from the Class Library. This statement was needed before Release 6.20 if you wanted to access one of the static components of class from within a program, or to declare an event handler for class before class had been loaded automatically. From Release 6.20 onwards, the LOAD addition is only needed if the compilation of an ABAP program fails because it includes recursive accesses of a globa l class. In such cases, you may be able to make the program compilable by explicitly loading the class before recursion.

Thanks,

kranthi.

5 REPLIES 5
Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,286

Hello,

"Forward Declaration" is a programming style & is not specific to OO-ABAP. (Source: [http://en.wikipedia.org/wiki/Forward_declaration]).

These definitions are added in the PUBLIC SECTION of the class as TYPE-POOLS, CLASS DEFINITION LOAD, INTERFACE DEFINITION LOAD etc.

BR,

Suhas

Read only

Former Member
0 Likes
1,286

Hi Suhas,

This is the thing written in the F1 Help only. I want to make use of this or need a Use case where it is used exactly.

Regards,

Kapil.

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,286

Hello,

If you've a look at the class CL_ABAP_TYPEDESCR you'll have a idea how this helps.

In this class the type pool ABAP is defined in the "Forward Declaration" section & its' elements are used in defining the Attributes & Types of the class.

BTW why do you think you need to use the "Forward Declaration" feature?

BR,

Suhas

Read only

Former Member
0 Likes
1,286

Hi

Here u can insert the type pools or class or interface where elements you need are defined.

For example if you need the type for ALV you need to insert the type pool SLIS, in this way you'll be able to define your variablea as a type defined in SLIS

Max

Read only

Former Member
0 Likes
1,287

in addition to above replies, it can be used for classes and interfaces in that case Forward declaration is equivalent to

CLASS <class_name> DEFINITION LOAD. 

interface <interface_name> load

statements which are normally used in Program ( case for local classes )

use of Load from SAP docu

... LOAD

Effect

The variant with the LOAD addition loads a global class class from the Class Library. This statement was needed before Release 6.20 if you wanted to access one of the static components of class from within a program, or to declare an event handler for class before class had been loaded automatically. From Release 6.20 onwards, the LOAD addition is only needed if the compilation of an ABAP program fails because it includes recursive accesses of a globa l class. In such cases, you may be able to make the program compilable by explicitly loading the class before recursion.

Thanks,

kranthi.