Gerd Castan
Gerd Castan

Reputation: 6849

Using an include with constants in ABAP OO

I have an ABAP include containing only constants. (Not my code)

I want to use these constants in an ABAP OO method. (My code)

How can I use these constants in an object oriented ABAP environment without copying them?

The idea is to define these constants once and only once. And they are already defined in this include.

Additional question: is it possible to create a class that contains the constants of the above include in a public section, so that I do the include only once and use these constants in an object oriented way from other classes?

Upvotes: 5

Views: 5142

Answers (2)

vwegert
vwegert

Reputation: 18483

Assuming that the include really only contains constant definitions: From the Class Builder, select Goto --> Class-relevant Local Definitions and place an INCLUDE statement there. This should make the constants available throughout your implementation.

Upvotes: 8

Mauricio G Teixeira
Mauricio G Teixeira

Reputation: 11

  1. Will you need these constants just for this class? Create private atributes in the class.
  2. Will you use it in other classes (and programs as well)? Create and class with static components and use it everywhere...

Upvotes: -2

Related Questions