简体   繁体   English

在 ABAP OO 中使用包含常量

[英]Using an include with constants in ABAP OO

I have an ABAP include containing only constants.我有一个只包含常量的 ABAP 包含。 (Not my code) (不是我的代码)

I want to use these constants in an ABAP OO method.我想在 ABAP OO 方法中使用这些常量。 (My code) (我的代码)

How can I use these constants in an object oriented ABAP environment without copying them?如何在面向对象的 ABAP 环境中使用这些常量而不复制它们?

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?附加问题:是否可以在公共部分中创建一个包含上述包含的常量的类,以便我只包含一次并以面向对象的方式从其他类中使用这些常量?

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.假设 include 实际上只包含常量定义:从 Class Builder 中,选择Goto --> Class-relevant Local Definitions并在那里放置一个INCLUDE语句。 This should make the constants available throughout your implementation.这应该使常量在整个实现过程中可用。

  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...使用静态组件创建和分类并在任何地方使用它......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM