How To Fix OO_SOURCE_BASED035 - The protected section is positioned incorrectly in the class definition


SAP Error Message - Details

  • Message type: E = Error

  • Message class: OO_SOURCE_BASED - WB - Class Builder - Messages for the source-b. Class Editor

  • Message number: 035

  • Message text: The protected section is positioned incorrectly in the class definition

  • Show details Hide details
  • What causes this issue?

    The class can't be separated into its different source parts (public-,
    protected-, (package-,) private section or method implementation).

    System Response

    A warning will be sent and the changes won't be stored.

    How to fix this error?

    Please check whether the source contains the following statements:
    <EX>CLASS <class_name> DEFINITION.</>
    <EX>...</>
    <EX>ENDCLASS.</>

    The system issues an error message and will not allow you to continue with this transaction until the error is resolved.

    <EX>CLASS <class_name> IMPLEMENTATION.</>
    <EX> METHOD <method_name_1>.</>
    <EX> ...</>
    <EX> ENDMETHOD.</>
    <EX> ...</>
    <EX> METHOD <method_name_n>.</>
    <EX> ...</>
    <EX> ENDMETHOD.</>
    <EX>ENDCLASS.</>
    <EX>It is also important to check that the public-, protected-,
    (package-) and private section are in the correct order.</>
    <EX>The syntax check will help you to determine where the class
    structure is insufficient.</>

    Procedure for System Administrators


    Error message extract from SAP system. Copyright SAP SE.


Smart SAP Assistant

  • What is the cause and solution for SAP error message OO_SOURCE_BASED035 - The protected section is positioned incorrectly in the class definition ?

    The SAP error message OO_SOURCE_BASED035 indicates that there is an issue with the positioning of the protected section in a class definition. This error typically arises in ABAP Object-Oriented programming when the structure of the class does not adhere to the expected syntax rules.

    Cause:

    The error occurs when the PROTECTED section of a class is not placed correctly in relation to other sections such as PUBLIC and PRIVATE. In ABAP, the order of visibility sections in a class definition must follow a specific sequence:

    1. PUBLIC
    2. PROTECTED
    3. PRIVATE

    If the PROTECTED section is placed before the PUBLIC section or if there are any other structural issues in the class definition, this error will be triggered.

    Solution:

    To resolve this error, you need to check the class definition and ensure that the visibility sections are ordered correctly. Here’s how you can do that:

    1. Open the class definition in the ABAP editor.
    2. Verify the order of the visibility sections. Ensure that:
      • The PUBLIC section comes first (if it exists).
      • The PROTECTED section comes after the PUBLIC section.
      • The PRIVATE section comes last (if it exists).
    3. If the sections are out of order, rearrange them accordingly.

    Example:

    Here’s a correct structure for a class definition:

    CLASS my_class DEFINITION.
      PUBLIC SECTION.
        METHODS: public_method.
    
      PROTECTED SECTION.
        METHODS: protected_method.
    
      PRIVATE SECTION.
        DATA: private_data TYPE i.
    ENDCLASS.

    Related Information:

    • ABAP Class Definition: Understanding the structure of class definitions in ABAP is crucial. Familiarize yourself with the rules regarding visibility sections.
    • ABAP Documentation: Refer to the official SAP documentation for more details on class definitions and object-oriented programming in ABAP.
    • Debugging: If you encounter this error, use the ABAP editor's syntax check feature to identify and correct any other potential issues in your code.

    By following these guidelines, you should be able to resolve the OO_SOURCE_BASED035 error and ensure that your class definitions are correctly structured.

    • 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
The AI Support Assistant is great. It provides comprehensive assistance even on the most difficult issues. I highly recommend this service.
Rate 1
John Jordan
SAP Consultant & Author