How To Fix OO_SOURCE_BASED036 - The package 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: 036

  • Message text: The package 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_BASED036 - The package section is positioned incorrectly in the class definition ?

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

    Cause:

    The error occurs when the package section of a class definition is not placed correctly. In ABAP, the class definition must follow a specific order of sections, and the package section should be positioned correctly according to the ABAP syntax rules. The package section is used to define the package in which the class resides, and it should be placed after the visibility section (public, protected, private) and before the methods and attributes.

    Solution:

    To resolve this error, you need to check the class definition and ensure that the package section is correctly positioned. Here’s how you can do that:

    1. Check the Class Definition Order: Ensure that the class definition follows the correct order:

      • Visibility section (public, protected, private)
      • Package section (if applicable)
      • Attributes
      • Methods
    2. Correct the Positioning: If the package section is incorrectly placed, move it to the correct position in the class definition.

    3. Syntax Check: After making the changes, perform a syntax check to ensure that there are no other errors in the class definition.

    Example:

    Here’s a simplified example of a correct class definition:

    CLASS my_class DEFINITION
      INHERITANCE
        FOR TESTING
      FINAL
      CREATE PUBLIC.
    
      PUBLIC SECTION.
        " Public attributes and methods
      PROTECTED SECTION.
        " Protected attributes and methods
      PRIVATE SECTION.
        " Private attributes and methods
    
    ENDCLASS.
    
    CLASS my_class IMPLEMENTATION.
      " Implementation of methods
    ENDCLASS.

    Related Information:

    • ABAP Documentation: Refer to the official SAP documentation for ABAP programming to understand the structure of class definitions and the rules governing them.
    • SAP Community: You can also check the SAP Community forums for discussions related to this error, as other developers may have encountered similar issues and shared their solutions.
    • ABAP Development Tools: Use the ABAP Development Tools (ADT) in Eclipse for better syntax highlighting and error detection, which can help you identify such issues more easily.

    By following these steps, you should be able to resolve the OO_SOURCE_BASED036 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