Application Development 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: 

To check a record for existence in dbtable before using insert

Former Member
0 Kudos

Hi Experts:

My problem is that i have defined a foreign key in the Z database table and if i create entries directly through SE11, the check executes finely, but is i use insert command through module pool, all the entries are saved and the foreign key check is not executed.

Eg I want to check the plant entry in T001w, if it is there, only then that record should be saved, otherwise error message that please check your entry,

Is there any possiblity without using internal table.

Can we read through dbtable as we can in case of internal table?

Best Regards, Neetu

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You could do a select single from T001W before you Insert into your Z table to see if the entry exists. However, if you are doing multiple inserts it is more efficient to do a single load of the T001W records into an internal table, sort it and da a read using binary search.

I think T001W is fully buffered (a lot of these type of tables are) so the select is going to be reasonably efficient.

Andrew

1 REPLY 1

Former Member
0 Kudos

You could do a select single from T001W before you Insert into your Z table to see if the entry exists. However, if you are doing multiple inserts it is more efficient to do a single load of the T001W records into an internal table, sort it and da a read using binary search.

I think T001W is fully buffered (a lot of these type of tables are) so the select is going to be reasonably efficient.

Andrew