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

Checking Duplicate records in database table.

Former Member
0 Likes
845

Hi,

can anybody suggest me the way for below requirement,

i want to insert record(s) from internal table to database table, before that i have to check whether that database table contains the same record(s) which we are about to insert? and then insert if the "one"(record(s)) was not there.

can u suggest any simple way for this.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
613

Hi Kranthi,

First select all the data from DB table into <itab1> for all entries in ITAB2.

ITAB2 is your internal table

Loop at <itab2> into wa.

READ Table <itab1> into wa1 with key wa-keyfield.

If sy-subrc <> 0.

update wa values to DB Table.

Endif.

ENDLOOP.

<b>Reward Points if this helps</b>

Satish

3 REPLIES 3
Read only

Former Member
0 Likes
614

Hi Kranthi,

First select all the data from DB table into <itab1> for all entries in ITAB2.

ITAB2 is your internal table

Loop at <itab2> into wa.

READ Table <itab1> into wa1 with key wa-keyfield.

If sy-subrc <> 0.

update wa values to DB Table.

Endif.

ENDLOOP.

<b>Reward Points if this helps</b>

Satish

Read only

former_member194152
Contributor
0 Likes
613

Hi,

Make Primary Key in Database table so it will give error internally when u inserting duplicte records.

Regards

Gagan

Read only

former_member195698
Active Contributor
0 Likes
613

Use the Modify statement. If the record already exists it wil update the existing record, else it will insert a new record into the database.

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3ac8358411d1829f0000e829fbfe/content.htm

Regards,

Abhishek

Message was edited by:

Abhishek Jolly