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 directly into the database table

Former Member
0 Likes
2,773

Hi

I know that the INSERT statement allows me to enter the record directly in the database table without checking the foreign key

restrictions .

But what happens when the table entries are sent to the database system as the database(oracle) will not allow records without the foreign key check

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,834

Hello Hema,

if u r trying to update the standard tables using Insert query, and if the data is inconsistent then system will not allow you. This is because the while creating standard tables SAP has taken care that if and only if the corresponding record exists in the check table, then only allow the insertion.

this check is applied at application level using foreign key relationship. Checks at Database level is the second thing. See the figure.

But If you are maintaining inconsistent data in your own customized tables (Z-tables) and if you have not maintained the foreign key checks then system will allow you to insert the data. You can make this check required for system to check before inserting the data into the table.

Also see the Value Table field. for reference MAKT table is handful.

Regards,

Nikhil G.


6 REPLIES 6
Read only

arindam_m
Active Contributor
0 Likes
1,834

Short Dump...

Read only

Former Member
0 Likes
1,834

What is the error you are facing and what you want to implement..?

Read only

Former Member
0 Likes
1,834

SAP's OPEN SQL takes care of the interaction with the database and in case of any errors sets value of SY-SUBRC to 4. So by checking the value of SY-SUBRC you can know if the record got inserted successfully or not.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,834

The foreign key check are not actually created as constraints in the database when SAP ddic generate the tables/views, they are only checked programmatically in SAP.

So nothing should happened, provided you did not create such constraints in native SQL or directly in the database, in this caise an error will be raised, and if you don't catch it, dump will be generated.

Regards,

Raymond

Read only

Former Member
0 Likes
1,834

Can you please read SAP Help....

It gives detailed info as to what will happen.

Inserting Lines into Tables (SAP Library - ABAP Programming (BC-ABA))

Read

If the database table does not already contain a line with the same primary key as specified in the work area, the operation is completed successfully and SY-SUBRC is set to 0. Otherwise, the line is not inserted, and SY-SUBRC is set to 4.

Regards

Read only

Former Member
0 Likes
1,835

Hello Hema,

if u r trying to update the standard tables using Insert query, and if the data is inconsistent then system will not allow you. This is because the while creating standard tables SAP has taken care that if and only if the corresponding record exists in the check table, then only allow the insertion.

this check is applied at application level using foreign key relationship. Checks at Database level is the second thing. See the figure.

But If you are maintaining inconsistent data in your own customized tables (Z-tables) and if you have not maintained the foreign key checks then system will allow you to insert the data. You can make this check required for system to check before inserting the data into the table.

Also see the Value Table field. for reference MAKT table is handful.

Regards,

Nikhil G.