当前 CLASS POOL 中 PUBLIC class 的名称必须是“...”而不是“...”

The name of the PUBLIC class in the current CLASS POOL must be "..." not "..."

我正在尝试在全局 class (Z_MY_GLOBAL_CLASS) 中创建本地 class (Z_MY_LOCAL_CLASS),方法是在事务 "Local Definitions/Implementations" 中单击 se24.

之后,我将另一个 class 的源代码从其基于源代码的视图复制到单击 "local definitions" 按钮后显示的文本区域中。

*"* use this source file for the definition and implementation of
*"* local helper classes, interface definitions and type
*"* declarations

class Z_MY_LOCAL_CLASS definition
  public
  final
  create public .

public section.

  class-methods SOME_STATIC_METHOD
    importing
      !IS_IS type Z_SOME_TYPE
    returning
      value(RS_RETURN) type Z_SOME_TYPE .
protected section.
private section.
ENDCLASS.



CLASS Z_MY_LOCAL_CLASS IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method Z_MY_LOCAL_CLASS=>SOME_STATIC_METHOD
* +-------------------------------------------------------------------------------------------------+
* | [--->] IS_IN                   TYPE        Z_SOME_TYPE
* | [<-()] RS_RETURN               TYPE        Z_SOME_TYPE
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method SOME_STATIC_METHOD.
    "" some coding
  endmethod.
ENDCLASS.

尝试激活编码时,我收到以下消息:

The name of the PUBLIC class in the current CLASS POOL must be "Z_MY_GLOBAL_CLASS", not "Z_MY_LOCAL_CLASS".

或德语:

Der Name der PUBLIC-Klasse im aktuellen CLASS-POOL muß "Z_MY_GLOBAL_CLASS" statt "Z_MY_LOCAL_CLASS" lauten.

这是什么意思?

通常在 SAP/ABAP 中,错误消息并未描述实际错误。在您本地的定义中 class 更改这些行

class Z_MY_LOCAL_CLASS definition
  public
  final
  create public .

至此

class Z_MY_LOCAL_CLASS definition final create public.

它应该可以编译。所以问题是只允许全局classes包含public。当 copying/migrating 源代码从现有全局 classes 到本地 classes 时,您必须删除这些行。