The name of the PUBLIC class in the current CLASS POOL must be “…” not “…”

独自空忆成欢 提交于 2020-02-24 11:59:31

问题


I'm trying to create a local class (Z_MY_LOCAL_CLASS) inside a global class (Z_MY_GLOBAL_CLASS) by clicking "Local Definitions/Implementations" in transaction se24.

Afterwards I copied the source code of another class from its source code-based view into the text area that showed up after I clicked the "local definitions" button.

*"* 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.

When trying to activate the coding I get the following message:

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

or in German:

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

What does it mean?


回答1:


As often within SAP/ABAP the error message does not describe the actual error. In the definition of your local class change these lines

class Z_MY_LOCAL_CLASS definition
  public
  final
  create public .

to this

class Z_MY_LOCAL_CLASS definition final create public.

and it should compile. So the problem is that only global classes are allowed to contain public. When copying/migrating source code from existing global classes to local classes you have to remove those lines.



来源:https://stackoverflow.com/questions/58056207/the-name-of-the-public-class-in-the-current-class-pool-must-be-not

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!