Stop googling SAP errors. Use our Free Essentials plan instead - no credit card needed. Start Now

Close

How To Fix SDDL_PARSER_MSG018 - Number of fields in selection lists in unions must be the same


SAP Error Message - Details

  • Message type: E = Error

  • Message class: SDDL_PARSER_MSG - Message Class for DDL Parser

  • Message number: 018

  • Message text: Number of fields in selection lists in unions must be the same

  • 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 SDDL_PARSER_MSG018 - Number of fields in selection lists in unions must be the same ?

    The SAP error message SDDL_PARSER_MSG018 indicates that there is a mismatch in the number of fields in the selection lists of a union operation in your ABAP program or query. This error typically occurs when you are trying to combine the results of two or more SELECT statements using a UNION, but the number of fields (columns) in each SELECT statement does not match.

    Cause:

    The primary cause of this error is that the SELECT statements involved in the UNION do not have the same number of fields. For a UNION operation to be valid, each SELECT statement must return the same number of columns, and the corresponding columns must have compatible data types.

    Solution:

    To resolve this error, you should:

    1. Check the SELECT Statements: Review the SELECT statements that are part of the UNION. Ensure that each SELECT statement has the same number of fields.

    2. Align the Number of Fields: If one SELECT statement has more fields than another, you need to either:

      • Remove the extra fields from the SELECT statement that has more fields.
      • Add dummy fields (e.g., NULL values or default values) to the SELECT statement that has fewer fields to match the number of fields in the other SELECT statements.
    3. Ensure Data Type Compatibility: Make sure that the data types of the corresponding fields in each SELECT statement are compatible. For example, if one SELECT statement returns a string and another returns an integer, you may need to cast or convert the data types to ensure compatibility.

    Example:

    Here’s a simple example to illustrate the issue:

    DATA: lt_result TYPE TABLE OF your_structure.
    
    SELECT field1, field2 FROM table1 INTO TABLE lt_result.
    SELECT field1, field2, field3 FROM table2 INTO TABLE lt_result.  " This will cause the error

    To fix the error, you can modify the second SELECT statement to match the number of fields:

    DATA: lt_result TYPE TABLE OF your_structure.
    
    SELECT field1, field2 FROM table1 INTO TABLE lt_result.
    SELECT field1, field2, NULL AS field3 FROM table2 INTO TABLE lt_result.  " Now it matches

    Related Information:

    • UNION vs. UNION ALL: Remember that UNION removes duplicate records, while UNION ALL includes all records. The same rules apply regarding the number of fields.
    • Performance Considerations: Using UNION can have performance implications, especially with large datasets. Consider whether you need to use UNION or if there are alternative approaches.
    • Debugging: If you are unsure which SELECT statement is causing the issue, you can comment out one SELECT statement at a time to isolate the problem.

    By ensuring that all SELECT statements in your UNION have the same number of fields and compatible data types, you should be able to resolve the SDDL_PARSER_MSG018 error.

    • Do you have any question about this error?


      Upgrade now to chat with this error.


Instant HelpGet instant SAP help. Sign up for our Free Essentials Plan.


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