Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

To check a record for existence in dbtable before using insert

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

Tags:
Former Member
Former Member replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question