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

insert statements?

Former Member
0 Likes
1,620

hi

i had an program,to transfer few records from my itab to an ZTABLE,the program is working fine in DEV,but in QAS its giving dump on insert statments.

INSERT ZTAB2 FROM TABLE ITAB.

Please tell where is the prb?

why data is not uploading in my ITAB in QAS.

regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,521

Hi,

I suppose your internal table has more than one record with the same key,in such case you could use "accepting duplicate keys".

what it does is ,it will insert the vaild entry with the key for the first time,if your internal tavble contains more than one record with the same key ,it will ignore.

START-OF-SELECTION.

.

.

APPEND wa_test TO it_test.

.

.

INSERT z01test1 FROM TABLE it_test ACCEPTING DUPLICATE KEYS.

IF sy-subrc EQ 0.

MESSAGE 'not insterted' TYPE 'I'.

ELSE.

INSERT z01test1 FROM TABLE it_test ACCEPTING DUPLICATE KEYS.

IF sy-subrc EQ 0.

MESSAGE 'not insterted2' TYPE 'I'.

ELSE.

MESSAGE 'insterted2' TYPE 'I'.

ENDIF.

Even you can try out for Modify statement ....

MODIFY dbtab FROM TABLE itab.

Hope this will help you.

thanx,

dhanashri.

14 REPLIES 14
Read only

Former Member
0 Likes
1,521

tell me what is dump saying

If any of entry is already exist in the table then it will make dump on insert the same entry.

add a validation query on the table to find out whether entry already exist or not.

Do not use below the statement as you given

use like that

INSERT INTO dbtab VALUES wa

Regarsd

rajesh

Edited by: RAJESH KUMAR on Aug 4, 2008 11:05 AM

Edited by: RAJESH KUMAR on Aug 4, 2008 11:06 AM

Edited by: RAJESH KUMAR on Aug 4, 2008 11:07 AM

Read only

0 Likes
1,521

Hi

Dump:

An exception occurred that is explained in detail below.

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

and

therefore caused a runtime error.

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, results in termincation.

But in my ZTAB2,there is no such entry for the key,table is empty,for which I am uploading the data.

Read only

0 Likes
1,521

Hi Vipin do as i said in my previous suggetion

rgds

Rajesh

Read only

0 Likes
1,521

> But in my ZTAB2,there is no such entry for the key,table is empty,for which I am uploading the data.

Double check that in the internal table that you are using to do the updates that you don't have the same value (same key) twice, otherwise you will have issues. Even though there is no existing record in the DB table the internal table is passing two records that collide with each other and this will cause the dump.

Note - The easiest way to check this woud be via the debugger.

~Ian

Edited by: Ian Maxwell on Aug 4, 2008 1:42 AM

Read only

0 Likes
1,521

but tel me one more thing,before inserting the records I am also deleting the earlier records with same key.

like ob bank & plant i am insterting,but before it i am writing :

DELETE FROM ZTAB2 WHERE WERKS = WERKS

AND BANKNO = BANKNO.

still its not inserting into table.

Vipin

Read only

0 Likes
1,521

>but tel me one more thing,before inserting the records I am also deleting the earlier records with same key.

>like ob bank & plant i am insterting,but before it i am writing :

>DELETE FROM ZTAB2 WHERE WERKS = WERKS

>AND BANKNO = BANKNO.

But if your internal table has the same key twice this will also cause it to dump. You'll either have to ger rid of duplicates from your internal table or add on the "Accepting duplicate keys" extension to your insert statement.

Example:

Internal table has:

A

B

A

C

D

E

F

DB table has:

G

H

I

J

When you insert the internal table records into the DB table, this will cause a dump becuase the internal table has the value "A" twice. It will attempt to insert the first record and then the second one will cause it to dump and the entire DB transaciton will then be aborted.

Use a breakpoint and check the contents of the internal table prior to the insert.

~Ian

~Ian

Read only

Former Member
0 Likes
1,521

Hi,

check wheather you have done checking for insertion of duplicate data. your ITAB might try to insert duplicate data to Ztable.

For further detail, check

http://help.sap.com/saphelp_nw04/helpdata/en/c4/93d942f7ca45b69dfdfd424c38332e/conten

Anirban

Read only

Former Member
0 Likes
1,521

check weather u have trasfored all the things properly to Qty r not

data element.

domain.

check weather the structure is same r not.

Regards

Anbu

Read only

Former Member
0 Likes
1,521

hiii

same question here in link..i hope you get some solution from it..

regards

twinkal

Read only

ian_maxwell2
Active Participant
0 Likes
1,521

>i had an program,to transfer few records from my itab to an ZTABLE,the program is working fine in ?DEV,but in QAS its giving dump on insert statments.

What is the error that it is giving? Can you provide additional information.

Based on the minimal information provided I would make a guess that there is a chance that you are accidentily trying to insert a duplicate record and this specific case never showed up in your Dev environment. If this is the case then you will have to look at your data and logic and understand why you would be getting a duplicate and do any required program changes to prevent it from happening.

This was just a guess. If you post the specifics of the dump then I'm sure we'll be able to tell you what's happening.

~Ian

Read only

Former Member
0 Likes
1,521

Hi Vipin,

Are all the transport requests were sent correctly to the Quality system?

Were the customization maintained in qaulity system?

paste the dump ....

Mohinder

Read only

Former Member
0 Likes
1,521

Hi,

see below notes...

INSERT { {INTO target VALUES source }

| { target FROM source } }.

Effect

The INSERT statement inserts one or more rows specified in source in the database table specified in target. The two variants with INTO and VALUES or without INTO with FROM behave identically, with the exception that you cannot specify any internal tables in source after VALUES.

System Fields

The INSERT statement sets the values of the system fields sy-subrc and sy-dbcnt.

sy-subrc Meaning

0 At least one row was inserted.

4 At least one row could not be inserted, because the database table already contains a row with the same primary key or a unique secondary index.

The INSERT statement sets sy-dbcnt to the number of rows inserted.

Note

The inserted rows are finally included in the table in the next database commit. Up until this point, they can still be removed by a database rollback.

The statement INSERT sets a database lock until the next database commit or rollback. If used incorrectly, this can lead to a deadlock.

The number of rows that can be inserted in the tables of a database within a database LUW is limited, since a database system can only manage a limited amount of locks and data in the rollback area.

Read only

Former Member
0 Likes
1,522

Hi,

I suppose your internal table has more than one record with the same key,in such case you could use "accepting duplicate keys".

what it does is ,it will insert the vaild entry with the key for the first time,if your internal tavble contains more than one record with the same key ,it will ignore.

START-OF-SELECTION.

.

.

APPEND wa_test TO it_test.

.

.

INSERT z01test1 FROM TABLE it_test ACCEPTING DUPLICATE KEYS.

IF sy-subrc EQ 0.

MESSAGE 'not insterted' TYPE 'I'.

ELSE.

INSERT z01test1 FROM TABLE it_test ACCEPTING DUPLICATE KEYS.

IF sy-subrc EQ 0.

MESSAGE 'not insterted2' TYPE 'I'.

ELSE.

MESSAGE 'insterted2' TYPE 'I'.

ENDIF.

Even you can try out for Modify statement ....

MODIFY dbtab FROM TABLE itab.

Hope this will help you.

thanx,

dhanashri.

Read only

Former Member
0 Likes
1,521

Hi Vipin,

If any duplicate entry is found in your ITAB then it goes for a dump . Check ITAB if there is any duplicate entries exist.

Regards,

Rajitha.