2013 Feb 21 11:17 AM
Dear All,
I had Create one MOdule- Pool Programme. when i insert data in Z DB table only update first line. multiple line item are not inserted in DB table.
Code is Below.
INSERT zgateentry
FROM TABLE IT_INSERT
ACCEPTING DUPLICATE KEYS.
Regards,
Rakesh,
2013 Feb 21 12:33 PM
2013 Feb 21 11:23 AM
hi,
loop it_insert into wa_insert.
insert zgateentry from wa_insert.
endloop.
try this ....
hope it helps,
Vinoth
2013 Feb 21 11:39 AM
Hi Rakesh,
If a row with the same primary key or the same unique secondary index exists in
the database table for one or more of the rows to be inserted, these rows cannot
be inserted.
If addition ACCEPTING DUPLICATE KEYS is specified, all rows will be inserted which satisfies the condition duplicate keys and the remaining rows are rejected and sy-subrc equal to 4.u can check sy-dbcnt will shown the number of rows inserted.
Regards,
Vignesh Yeram
2013 Feb 21 11:40 AM
Hi Rakesh,
If a row with the same primary key or the same unique secondary index exists in
the database table for one or more of the rows to be inserted, these rows cannot
be inserted.
If addition ACCEPTING DUPLICATE KEYS is specified, all rows will be inserted which satisfies the condition duplicate keys and the remaining rows are rejected and sy-subrc equal to 4.u can check sy-dbcnt will shown the number of rows inserted.
Regards,
Vignesh Yeram
2013 Feb 21 11:53 AM
Hi,
It should work. Can you post the contents of your internal table? I hope you are not expecting duplicate records to be inserted in the database table. That won't happen even if you use ACCEPTING DUPLICATE KEYS. This addition does not allow you to add duplicate records in a database table. Just that if your internal table has duplicate records, it prevents a runtime error if you try to insert those records in the database. If your internal table has duplicate records and you don't use the addition ACCEPTING DUPLICATE KEYS, then you would get a runtime error.
2013 Feb 21 12:04 PM
Hi Akshat,
I meant the same, may be where Rakesh is trying, internal table might contain duplicate records.it's better if he post the contents of the internal table.
If a row with the same primary key or the same unique secondary index exists in
the database table for one or more of the rows to be inserted, these rows cannot
be inserted it will give dump
If addition ACCEPTING DUPLICATE KEYS is specified, all rows will be inserted which is unique and the remaining rows are rejected and sy-subrc equal to 4.you can check sy-dbcnt will shown the number of rows inserted.
Regards,
Vignesh Yeram
2013 Feb 21 12:33 PM
2013 Feb 21 4:38 PM
Hi Rakesh,
Syntax is :-
1) INSERT dbtab FROM table itab ACCEPTING DUPLICATE KEYS.
Could you please paste the entries present in internal table and database table so that it will be better to understand the expected output from you and the problem.
2) if this does not work please use:-
MODIFY dbtab FROM itab.
COMMIT WORK.
It is better to update database table once instead of hitting the database again n again inside the loop.
Regards,
Vignesh Yeram
2013 Feb 22 4:00 AM
Dear vignesh,
i had already use both syntax but not working.
my internal table data are below,
| 2 1 000000000130 20130222 RAKES RAKESH AADDINATH CORPORATION FDAS SPLENDER 231321 090243 000000 |
2 2 000000000130 20130222 RAKES RAKESH AADDINATH CORPORATION FDAS SPLENDER HULB 090243 000000
in iternal table there is 2 line item but, in DB table store only one line Item.in DB Table one Primary key. first row (2) is Primarty key.
In DB Table :
| 2 | 1 | 000000000130 | 20130222 | RAKES | RAKESH | AADDINATH CORPORATION | FDAS | SPLENDER | 231321 | 090243 | 000000 |
store only first Entry...
Regards,
Rakesh
2013 Feb 22 9:25 AM
Dear Rakesh,
If a row with the same primary key or the same unique secondary index exists in
the database table for one or more of the rows to be inserted, these rows cannot
be inserted, it means in ur case primary key is the first only field 000000000130 in it is already present in DB table, so you try to insert same value 000000000130 again it will not be inserted it will give dump. if dump is to be avoided then u can also use
INSERT dbtab FROM table itab ACCEPTING DUPLICATE KEYS
But in this case also same primary key will not be inserted it should be unique always.if the internal table contains two entries with same primary key only first entry will be inserted with above syntax if database table does not have the same primary key.
if you want to insert all the records you have to increase the primary key fields.
the concept is you cannot insert the same primary key again.
Hope above explanation helps you.
Regards,
Vignesh Yeram
2013 Feb 21 12:37 PM
dear vinoth,
i had already use that but not working.
regards,
Rakesh
2013 Feb 22 4:05 AM
hi,
if you need all the entries don assign the key figure in the table ..
hope it helps,
Vinoth