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

Modify statemnt taking too much time

Former Member
0 Likes
1,924

Hi guys,

I need to insert new records into my db table if they do not exist or update records if they dont exist in the table.

Am using a modify statement .But this is taking 10 times more time than insert stmnt.

Is there any way to avoid modify stmnt and still implement my logic

Thanks

Hi guys,

I need to insert new records into my db table if they do not exist or update records if they dont exist in the table.

Am using a modify statement .But this is taking 10 times more time than insert stmnt.

Is there any way to avoid modify stmnt and still implement my logic

Thanks

7 REPLIES 7
Read only

Former Member
0 Likes
1,263

Hi,

You can do it this way :

Loop the internal table and check in your DB table if the record exist. <You do this by taking DB table record in another internal table and then reading this table. >.

If there is a record, use update statement else use insert statelemt.

This should solve your problem.

Regards,

Lalit Kabra

Read only

Former Member
0 Likes
1,263

hi,

Apart from using the MODIFY statement, the content of an individual table line can be changed using assignments to field symbols and dereferenced data references that point to the table line.

Read only

ritesh_dugad2
Active Participant
0 Likes
1,263

try to use the statement like this:

modify <dbtab> from table itab.

This is faster and good in performance. Only thing is that your itab structure should be same as that of your database table.

Read only

Former Member
0 Likes
1,263

Hi,

MODIFY itab - itab_line TRANSPORTING comp1 comp2 ...

MODIFY itab - itab_lines itab FROM wa TRANSPORTING comp1 comp2 ... WHERE log_exp.

Even above 2 stmts improves can improve performance.

Edited by: Prince on Jun 4, 2008 12:35 PM

Read only

0 Likes
1,263

Hi Prince ,

Couldnt understand.Could you be a little more explicit.

Thanks a lot

Others please help too

Read only

0 Likes
1,263

True, Prince used to be more explicit back in the Eighties...

In this case he's on the wrong trip, because you are talking about DB update, while he is referring to internal table operations.

Sometimes your program logic already allows you to collect the data in separate internal tables XXX_INS and XXX_UPD, which you can then use to perform the INSERT and UPDATE statements. This would be the most effective way.

I've seen people using an INSERT ... ACCEPTING DUPLICATE KEYS and then UPDATE the entire data, which is quite quick and dirty.

Greetings

Thomas

Read only

Former Member
0 Likes
1,263

Hi ankit!

For the scenerio that u ahve mentioned

there are two options either u use modify statement(do F1 on modify u will get all syntax related to it) else u can check ur itab if it has records.

If the records exists then use insert else use update.

rewrd if useful.