Open SQL array insert produces duplicate records in the database.

What happened?
    Error in the ABAP Application Program

    The current ABAP program "ZTESTPROGRAM" had to be terminated because it has
    come across a statement that unfortunately cannot be executed.

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
    "TEST_DATA" "(FORM)", 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 "ZGT_TABLE" 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
     "TEST_DATA" "(FORM)", 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

Comments

Popular posts from this blog

all user exit mv45afzz (implicit user exit )

MB_MIGO_BADI THIS BADI USED TO POSTING DATA IN MIGO

Long Text in input and output field in module pool