Application Development and Automation 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: 
Read only

Exception occured while entering the data in database

Former Member
0 Likes
1,326

Hi All,

An exception occurred that is explained in detail below.     

The exception, which is assigned to class 'CX_SY_OPEN_SQL_DB', was not caught     

in     procedure "UPDATE_TABLES" "(FORM)", nor was it propagated by a RAISING clause.     

Since the caller of the procedure could not have anticipated that the     

exception would occur, the current program is terminated.     

The reason for the exception is:     

If you use an ABAP/4 Open SQL array insert to insert a record in     

the database and that record already exists with the same key,     

this results in a termination.     

     

(With an ABAP/4 Open SQL single record insert in the same error     

situation, processing does not terminate, but SY-SUBRC is set to 4.)     

Below is the code:-

DATA: z_subrc_header_pres LIKE sy-subrc,       

        z_subrc_item_pres LIKE sy-subrc,       

        z_dbcnt_header_pres LIKE sy-dbcnt,       

        z_dbcnt_item_pres LIKE sy-dbcnt,       

        z_subrc_header_wip LIKE sy-subrc,       

        z_subrc_item_wip LIKE sy-subrc,       

        z_dbcnt_header_wip LIKE sy-dbcnt,       

        z_dbcnt_item_wip LIKE sy-dbcnt,       

        z_subrc_dealitem_txt LIKE sy-subrc,       

        z_dbcnt_dealitem_txt LIKE sy-dbcnt.       

       

  DATA: t_head_wip TYPE TABLE OF /tmw/header_wip,       

        t_item_wip TYPE TABLE OF /tmw/item_wip,       

        z_head_wip LIKE LINE OF t_head_wip,       

        z_item_wip LIKE LINE OF t_item_wip.       

       

       

       

  LOOP AT t_ztmw_header_pres INTO z_ztmw_header_pres.       

    MOVE-CORRESPONDING z_ztmw_header_pres TO z_head_wip.       

    APPEND z_head_wip TO t_head_wip.       

  ENDLOOP.       

       

  LOOP AT t_ztmw_item_pres INTO z_ztmw_item_pres.       

    MOVE-CORRESPONDING z_ztmw_item_pres TO z_item_wip.       

    APPEND z_item_wip TO t_item_wip.       

  ENDLOOP.       

       

*updata pristine tables        .

>>>> INSERT /tmw/header_pres FROM TABLE t_ztmw_header_pres.        " In this sentence it is showing dump

  z_subrc_header_pres = sy-subrc.       

  z_dbcnt_header_pres = sy-dbcnt.       

  INSERT /tmw/item_pres FROM TABLE t_ztmw_item_pres.       

  z_subrc_item_pres = sy-subrc.       

  z_dbcnt_item_pres = sy-dbcnt.       

       

*update WIP tables       

  INSERT /tmw/header_wip FROM TABLE t_head_wip.       

  z_subrc_header_wip = sy-subrc.       

  z_dbcnt_header_wip = sy-dbcnt.       

  INSERT /tmw/item_wip FROM TABLE t_item_wip.       

  z_subrc_item_wip = sy-subrc.       

  z_dbcnt_item_wip = sy-dbcnt.       

       

*update partner pres and wip tables       

  INSERT /tmw/part_pres FROM TABLE t_ztmw_part_pres.       

  z_subrc_part_pres = sy-subrc.       

  INSERT /tmw/part_wip FROM TABLE t_ztmw_part_pres.       

  z_subrc_part_wip = sy-subrc.   


When i debug and checked i didn't find any duplicate records. Plz help me out.


















































































































































































































































































































  DATA:
  z_subrc_header_pres LIKE sy-subrc,
        z_subrc_item_pres LIKE sy-subrc,
        z_dbcnt_header_pres LIKE sy-dbcnt,
        z_dbcnt_item_pres LIKE sy-dbcnt,
        z_subrc_header_wip LIKE sy-subrc,
        z_subrc_item_wip LIKE sy-subrc,
        z_dbcnt_header_wip LIKE sy-dbcnt,
        z_dbcnt_item_wip LIKE sy-dbcnt,
        z_subrc_dealitem_txt LIKE sy-subrc,
        z_dbcnt_dealitem_txt LIKE sy-dbcnt.
  DATA: t_head_wip TYPE TABLE OF
  /tmw/header_wip,
        t_item_wip TYPE TABLE OF
  /tmw/item_wip,
        z_head_wip LIKE LINE OF t_head_wip,
        z_item_wip LIKE LINE OF t_item_wip.
  LOOP AT t_ztmw_header_pres INTO
  z_ztmw_header_pres.
    MOVE-CORRESPONDING z_ztmw_header_pres TO z_head_wip.
    APPEND z_head_wip TO t_head_wip.
  ENDLOOP.
  LOOP AT t_ztmw_item_pres INTO
  z_ztmw_item_pres.
    MOVE-CORRESPONDING z_ztmw_item_pres TO
  z_item_wip.
    APPEND z_item_wip TO t_item_wip.
  ENDLOOP.
*updata
  pristine tables
  INSERT /tmw/header_pres FROM TABLE
  t_ztmw_header_pres.
  z_subrc_header_pres = sy-subrc.
  z_dbcnt_header_pres = sy-dbcnt.
  INSERT /tmw/item_pres FROM TABLE
  t_ztmw_item_pres.
  z_subrc_item_pres = sy-subrc.
  z_dbcnt_item_pres = sy-dbcnt.
*update WIP
  tables
  INSERT /tmw/header_wip FROM TABLE
  t_head_wip.
  z_subrc_header_wip = sy-subrc.
  z_dbcnt_header_wip = sy-dbcnt.
  INSERT /tmw/item_wip FROM TABLE t_item_wip.
  z_subrc_item_wip = sy-subrc.
  z_dbcnt_item_wip = sy-dbcnt.
*update
  partner pres and wip tables
  INSERT /tmw/part_pres FROM TABLE
  t_ztmw_part_pres.
  z_subrc_part_pres = sy-subrc.
  INSERT /tmw/part_wip FROM TABLE
  t_ztmw_part_pres.
  z_subrc_part_wip = sy-subrc.


 


Database commit
  failed.
6 REPLIES 6
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,106

Did you check sys log (SM21) for SQL error messages ?


Regards,

Raymond

Read only

Former Member
0 Likes
1,106

Hi Sirisha,

Check the existing records in the table. If a record with an existing set of primary keys is inserted, you will get a dump.

Regards,

Gautam.

Read only

0 Likes
1,106

I checked it .No duplicate records are there. Other than this is there any other issue for this dump.

Read only

0 Likes
1,106

Hi Sirisha,

That is the only issue I can interpret from the dump. I believe it is caused by either of the following:

1. The database table contains records with the same set of key fields which you are trying to insert.

2. The internal table with which you are trying to update the database table contains multiple records with the same set of primary keys. Kindly check this in the debug mode.

Let us know if this helps you.

Regards,

Gautam

Read only

marcosmata
Participant
0 Likes
1,106

Hey, can you post the DUMP as showed in ST22? (Please post as an image)

Read only

Former Member
0 Likes
1,106

'Hi Sirisha,

Yes the error is due to same record exists.

use MODIFY databse_table FROM wa

  MODIFY database_table FROM TABLE internal_table

It is always safe to use modify .. it adds a row if no such record exists ele modifies the record.

In debugging if no duplicate record is there then may be database table contains the same record already.

Thanks

Rahul