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

short dump when database updating

Former Member
0 Likes
1,798

Hi all,

I'm updating database by using insert statements. i'm deleting all the duplicate entries. eventhough i'm getting dump. dump error is like this

" 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.) "

bellow is my code.

SORT: itab1, itab2 BY f1 f2 f3 f4.

DELETE ADJACENT DUPLICATES FROM itab1 comparing all fields.

DELETE ADJACENT DUPLICATES FROM itab2 comparing all fields.

  • remove already existing entries for tcode

SELECT * FROM db_tab1

INTO TABLE itab3

WHERE edate = pdate.

SORT itab3 by f1 f2 f3 f4.

LOOP AT itab1.

READ TABLE itab3 WITH KEY f1 = itab1-f1

f2 = itab1-f2

f3 = itab1-f3

f4 = itab1-f4

BINARY SEARCH TRANSPORTING NO FIELDS.

CHECK sy-subrc = 0.

DELETE itab1.

ENDLOOP.

  • remove already existing entries for program ID

SELECT * FROM db_tab2

INTO TABLE itab4

WHERE edate = pdate.

SORT itab4 by f1 f2 f3 f4.

LOOP AT itab2.

READ TABLE itab4 WITH KEY f1 = itab2-f1

f2 = itab2-f2

f3 = itab2-f3

f4 = itab2-f4

BINARY SEARCH TRANSPORTING NO FIELDS.

CHECK sy-subrc = 0.

DELETE itab2.

ENDLOOP.

CLEAR itab1.

IF NOT itab1[] IS INITIAL.

  • INSERT db_tab1 FROM TABLE itab1.

COMMIT WORK.

IF NOT itab2[] IS INITIAL.

INSERT db_tab2 FROM TABLE itab2.

COMMIT WORK.

please show me a solution. if i use modify statement i hope it will get solved. but i want to know why its giving dump even i'm deleting all the duplicate entries.

One more thing my report is scheduled for bacground job.

Thanks

g.s.naidu

1 ACCEPTED SOLUTION
Read only

former_member585060
Active Contributor
0 Likes
1,464

Hi,

Declare work areas for the declared internal tables, and use the following syntax and try to delete already existing records. Use same for second internal table also.

  • remove already existing entries for tcode

SELECT * FROM db_tab1

INTO TABLE itab3

WHERE edate = pdate.

SORT itab3 by f1 f2 f3 f4.

LOOP AT itab1 INTO wa_itab1.

READ TABLE itab3 WITH KEY f1 = wa_itab1-f1

f2 = wa_itab1-f2

f3 = wa_itab1-f3

f4 = wa_itab1-f4

BINARY SEARCH TRANSPORTING NO FIELDS.

IF sy-subrc = 0

DELETE table itab1 from wa_itab1.

ENDIF.

ENDLOOP.

Regards

Bala Krishna

Hi,

Declare work areas for the declared internal tables, and use the following syntax and try to delete already existing records. Use same for second internal table also.

  • remove already existing entries for tcode

SELECT * FROM db_tab1

INTO TABLE itab3

WHERE edate = pdate.

SORT itab3 by f1 f2 f3 f4.

LOOP AT itab1 INTO wa_itab1.

READ TABLE itab3 WITH KEY f1 = wa_itab1-f1

f2 = wa_itab1-f2

f3 = wa_itab1-f3

f4 = wa_itab1-f4

BINARY SEARCH TRANSPORTING NO FIELDS.

IF sy-subrc = 0

DELETE table itab1 from wa_itab1.

ENDIF.

ENDLOOP.

Regards

Bala Krishna

5 REPLIES 5
Read only

Former Member
0 Likes
1,464

Hi

You are deleting duplicate entries from Internal table.

Before running the program check that the entry you want to insert is already exist in Database table.

If yes then it will give a dump.

Regards

Aditya

Read only

0 Likes
1,464

Hi Aditya,

You are right. but i'm deleting the records which are already in the database also. you can observe that in my code. here i'm deleting duplicate entries from itab and after that i'm checking for already existing records from database table also.

Thanks

g.s.naidu

Read only

Former Member
0 Likes
1,464

Before entering in the database check whether the entry already exists in table or not.

Read only

former_member585060
Active Contributor
0 Likes
1,465

Hi,

Declare work areas for the declared internal tables, and use the following syntax and try to delete already existing records. Use same for second internal table also.

  • remove already existing entries for tcode

SELECT * FROM db_tab1

INTO TABLE itab3

WHERE edate = pdate.

SORT itab3 by f1 f2 f3 f4.

LOOP AT itab1 INTO wa_itab1.

READ TABLE itab3 WITH KEY f1 = wa_itab1-f1

f2 = wa_itab1-f2

f3 = wa_itab1-f3

f4 = wa_itab1-f4

BINARY SEARCH TRANSPORTING NO FIELDS.

IF sy-subrc = 0

DELETE table itab1 from wa_itab1.

ENDIF.

ENDLOOP.

Regards

Bala Krishna

Read only

Former Member
0 Likes
1,464

Hello Naidu,

Instead of using INSERT use MODIFY it will insert if the record is not there else updates the existing record

MODIFY dbtab from table ITAB.

for more info please go through the F1 help

Best Regards

Ramchander Rao.K