Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Dump DBSQL_DUPLICATE_KEY_ERROR in transaction me22n

Former Member
0 Kudos

Hello Friends,

In transaction me22n  I am getting below dump. IN FM "ME_UPDATE_DOCUMENT" at insert statement for table POEXT

  Is anybody has face same issue. Kindly suggest how to prevent from this dump.

Category               ABAP Programming Error
Runtime Errors         DBSQL_DUPLICATE_KEY_ERROR
Except.                CX_SY_OPEN_SQL_DB
ABAP Program           SAPLEINU
Application Component  MM-PUR
Date and Time          15.06.2016 14:35:13
----------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------
|Short Text                                                                                        |
|    Open SQL array insert produces duplicate records in the database.                             |
----------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------
|What happened?                                                                                    |
|    Error in the ABAP Application Program                                                         |
|                                                                                                  |
|    The current ABAP program "SAPLEINU" had to be terminated because it has                       |
|    come across a statement that unfortunately cannot be executed.                                |
----------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------
|What can you do?                                                                                  |
|    Note down which actions and inputs caused the error.                                          |
|                                                                                                  |
|                                                                                                  |
|    To process the problem further, contact you SAP system                                        |
|    administrator.                                                                                |
|                                                                                                  |
|    Using Transaction ST22 for ABAP Dump Analysis, you can look                                   |
|    at and manage termination messages, and you can also                                          |
|    keep them for a long time.                                                                    |
----------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------
|Error analysis                                                                                    |
|    An exception has occurred which is explained in more detail below. The                        |
|    exception is assigned to class 'CX_SY_OPEN_SQL_DB' and was not caught in                      |
|     procedure                                                                                    |
|    "ME_UPDATE_DOCUMENT" "(FUNCTION)", nor was it propagated by a RAISING clause.                 |
|    Since the caller of the procedure could not have anticipated this                             |
|    exception, the current program was terminated.                                                |
|    The reason for the exception is:                                                              |
|    When an Open SQL array insert is performed, trying to insert a record                         |
|    into the database table "POEXT" causes the function to terminate if a                         |
|    record with the same key already exists.                                                      |
|                                                                                                  |
|    (When an Open SQL individual record insert is performed, this situation                       |
|    does not cause the function to terminate. SY-SUBRC is set to 4 instead.)                      |
----------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------
|How to correct the error                                                                          |
|    The exception must either be prevented, caught in procedure                                   |
|     "ME_UPDATE_DOCUMENT" "(FUNCTION)", or                                                        |
|    the possibility of it occurring must be declared in the RAISING clause                        |
|    in the procedure.                                                                             |
|    To prevent the exception, note the following:                                                 |
|                                                                                                  |
|    Open SQL array insert should only be used if it is certain that none of                       |
|    the records specified already exists on the database. If this cannot be                       |
|    guaranteed, exception CX_SY_OPEN_SQL_DB should be intercepted, and the                        |
|    error must be resolved.                                                                       |
|    If the error occurs in a non-modfied SAP program, you might be able to                        |
|    find a solution in the SAP Notes system. If you have access to the SAP                        |
|    Notes system, check there first using the following keywords:                                 |
|                                                                                                  |
|    "DBSQL_DUPLICATE_KEY_ERROR" CX_SY_OPEN_SQL_DB                                                 |
|    "SAPLEINU" bzw. LEINUU05                                                                      |
|    "ME_UPDATE_DOCUMENT"                                                                          |
|    If you cannot solve the problem yourself, please send the following                           |
|    information to SAP:                                                                           |
|                                                                                                  |
|    1. This description of the problem (short dump)                                               |
|    To do this, choose  System -> List -> Save -> Local File (unconverted)                        |
|    on the screen you are in now.                                                                 |
|                                                                                                  |
|    2. A suitable system log                                                                      |
|    To do this, call the system log in transaction SM21. Restrict the time                        |
|    interval to ten minutes before the short dump and five minutes after                          |
|    it. In the display, choose System -> List -> Save -> Local File                               |
|    (unconverted).                                                                                |
|                                                                                                  |
|    3. If these are programs of your own, or modified SAP programs: Source                        |
|    code of these programs                                                                        |
|    To do this, choose  More Utilities -> Upload/Download -> Download in                          |
|    the Editor.                                                                                   |
|                                                                                                  |
|    4. Details regarding the conditions under which the error occurred or                         |
|    which actions and input caused the error.                                                     |
----------------------------------------------------------------------------------------------------


|  771|      t_yekpo = yekpo                                                                       |
|  772|      t_yeket = yeket                                                                       |
|  773|      t_yekkn = yekkn                                                                       |
|  774|    EXCEPTIONS                                                                              |
|  775|      OTHERS  = 0.                                                                          |
|  776|*                                                                                           |
|  777|                                                                                            |
|  778|*------- Fortschreibung Zusatzdaten POEXT NCF KH ----------------------*                    |
|  779|  DATA: lt_poext_db   TYPE me_poext,                                                        |
|  780|        lt_poext_db_u TYPE me_poext,                                                        |
|  781|        ls_poext      LIKE LINE OF lt_poext_db,                                             |
|  782|        ls_xpoext     LIKE LINE OF xpoext.                                                  |
|  783|  LOOP AT xpoext INTO ls_xpoext.                                                            |
|  784|    CLEAR ls_poext.                                                                         |
|  785|    MOVE-CORRESPONDING ls_xpoext TO ls_poext.                                               |
|  786|    CASE ls_xpoext-update.                                                                  |
|  787|      WHEN 'I'.                                                                             |
|  788|        APPEND ls_poext TO lt_poext_db.                                                     |
|  789|      WHEN 'U'.                                                                             |
|  790|        APPEND ls_poext TO lt_poext_db_u.                                                   |
|  791|    ENDCASE.                                                                                |
|  792|  ENDLOOP.                                                                                  |
|  793|  DESCRIBE TABLE lt_poext_db LINES sy-tfill.                                                |
|  794|  IF sy-tfill GT 0.                                                                         |
|>>>>>|    INSERT poext FROM TABLE lt_poext_db.                                                    |
|  796|    IF sy-subrc NE 0.                                                                       |
|  797|      MESSAGE a807 WITH 'POEXT'.                                                            |
|  798|    ENDIF.                                                                                  |
|  799|  ENDIF.                                                                                    |
|  800|  DESCRIBE TABLE lt_poext_db_u LINES sy-tfill.                                              |
|  801|  IF sy-tfill GT 0.                                                                         |
|  802|    UPDATE poext FROM TABLE lt_poext_db_u.                                                  |
|  803|    IF sy-subrc NE 0.                                                                       |
|  804|      MESSAGE a808 WITH 'POEXT'.                                                            |
|  805|    ENDIF.                                                                                  |
|  806|  ENDIF.                                                                                    |
|  807|*                                                                                           |

3 REPLIES 3

Sandra_Rossi
Active Contributor
0 Kudos

Did you really search before posting? because I could easily find the probable reason and solution. Please close the thread after you have searched and found the solution.

0 Kudos

Hi Sandra,

Yes I tried to search it and I know the root cause. Root cause already explained in dump itself " When an Open SQL array insert is performed, trying to insert a record  into the database table "POEXT" causes the function to terminate a record with the same key already exists".

I want  know the is solution.

0 Kudos

Searching means Google and SAP notes. Searching ME_UPDATE_DOCUMENT POEXT gives a result -> SAP note