How To Fix EU346 - You cannot use internal subroutines in a global class


SAP Error Message - Details

  • Message type: E = Error

  • Message class: EU - Development Environment

  • Message number: 346

  • Message text: You cannot use internal subroutines in a global class

  • Show details Hide details


  • Self-Explanatory Message

    Since SAP believes that this specific error message is 'self-explanatory,' no more information has been given.The majority of messages in the SAP system have a message text, however this is frequently insufficient to comprehend or resolve the problem.

    To make things easier, more detailed information is frequently added to describe the issue, how to fix it, and the necessary steps or configuration modifications.

    Unfortunately, there isn't any extra information in this error notice.



    What else can you do?

    First, use our AnswerBot below to get a possible cause and solution (requires a premium subscription).

    Also, review the in-depth Common Questions & Answers listed below; you could discover a solution there or be able to connect with others who have faced similar challenges.

    You can also try searching the SAP support portal (support.sap.com) but you need a special user ID to access it. It is possible that an SAP support note exists that provides additional details about the mistake or even steps for fixing it.


Smart SAP Assistant

  • What is the cause and solution for SAP error message EU346 - You cannot use internal subroutines in a global class ?

    The SAP error message EU346, which states "You cannot use internal subroutines in a global class," typically occurs when you attempt to define internal subroutines (also known as FORM routines) within a global class in ABAP (Advanced Business Application Programming). In ABAP, global classes are part of the object-oriented programming paradigm, and they do not support the use of procedural programming constructs like internal subroutines.

    Cause:

    The error arises because:

    • Internal subroutines (defined using the FORM keyword) are only allowed in procedural programs or local classes.
    • Global classes are designed to encapsulate methods and attributes in an object-oriented manner, and they should use methods instead of internal subroutines.

    Solution:

    To resolve this error, you should replace the internal subroutines with methods. Here’s how you can do that:

    1. Define Methods: Instead of using FORM to define subroutines, define methods within your global class. For example:

      CLASS my_class DEFINITION.
        PUBLIC SECTION.
          METHODS: my_method.
      ENDCLASS.
      
      CLASS my_class IMPLEMENTATION.
        METHOD my_method.
          " Your code here
        ENDMETHOD.
      ENDCLASS.
    2. Call Methods: When you need to call the functionality that was previously in the internal subroutine, call the method instead. For example:

      DATA(lo_my_class) = NEW my_class( ).
      lo_my_class->my_method( ).

    Related Information:

    • Object-Oriented Programming in ABAP: Familiarize yourself with the principles of object-oriented programming in ABAP, including classes, methods, attributes, and inheritance.
    • ABAP Documentation: Refer to the official SAP documentation for more details on defining classes and methods in ABAP.
    • Best Practices: When transitioning from procedural to object-oriented programming, consider refactoring your code to take full advantage of encapsulation, inheritance, and polymorphism.

    By following these steps, you should be able to eliminate the EU346 error and properly structure your code using object-oriented principles in ABAP.

    • Do you have any question about this error?


      Upgrade now to chat with this error.


Instant HelpGet instant SAP help. Start your 7-day free trial now.


Related SAP Error Messages

Click the links below to see the following related messages:

Click on this link to search all SAP messages.


Rating
ERPlingo's SAP support assistant is amazing. Saves me countless hours trying to solve complex SAP issues myself. It's a real game changer!
Rate 1
Thomas Michael
SAP Consultant, Author & Speaker