How To Fix P0789 - Routine & contains one CENDIF statement too many


SAP Error Message - Details

  • Message type: E = Error

  • Message class: P0 - Messages for Transactions PE01, PE02 and PE03

  • Message number: 789

  • Message text: Routine & contains one CENDIF statement too many

  • Show details Hide details
  • What causes this issue?

    Routine &V1& contains one CEND

    System Response

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

    How to fix this error?

    Correct routine &V1& and use report RPUGCC00 to generate another
    personnel calculation rule check. If this is a routine delivered by
    SAP, please contact the SAP telephone service.

    Error message extract from SAP system. Copyright SAP SE.


Smart SAP Assistant

  • What is the cause and solution for SAP error message P0789 - Routine & contains one CENDIF statement too many ?

    The SAP error message "P0789 Routine & contains one CENDIF statement too many" typically occurs during the execution of ABAP programs or during the compilation of ABAP code. This error indicates that there is a mismatch in the control structures of the code, specifically with the IF and CENDIF statements.

    Cause:

    The error is caused by having an extra CENDIF statement in your code. In ABAP, every IF statement must have a corresponding ENDIF. If there are more CENDIF statements than IF statements, the compiler will raise this error.

    Solution:

    To resolve this error, you should:

    1. Review the Code: Go through the ABAP code where the error is reported. Look for the IF and CENDIF statements.

    2. Count the Statements: Ensure that each IF statement has a matching CENDIF. You can do this by counting the occurrences of each statement.

    3. Remove Extra CENDIF: If you find an extra CENDIF that does not correspond to an IF, remove it.

    4. Check Nested Structures: If you have nested IF statements, ensure that each nested IF has its own CENDIF and that they are correctly matched.

    5. Syntax Check: After making changes, perform a syntax check on the program to ensure that there are no further issues.

    Example:

    Here’s a simple example to illustrate the issue:

    IF condition1.
      " Some code
    ENDIF.
    IF condition2.
      " Some code
    ENDIF.
    CENDIF. " This will cause the error

    In the above example, the last CENDIF is unnecessary and should be removed.

    Related Information:

    • ABAP Syntax: Familiarize yourself with ABAP syntax rules regarding control structures. This will help prevent similar errors in the future.
    • Debugging Tools: Use the ABAP debugger and syntax check tools available in the SAP environment to identify and fix issues in your code.
    • Documentation: Refer to the official SAP documentation for more details on control structures and error handling in ABAP.

    By following these steps, you should be able to resolve the error and ensure that your ABAP code compiles and runs correctly.

    • 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 simplifies finding the accurate answers to SAP message errors. I now use every week. A must have tool for anyone working with SAP! Highly recommended!
Rate 1
Kent Bettisworth
Executive SAP Consultant