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

Abap performance

Former Member
0 Likes
858

HI ALl ,

In My program , i got one internal table (itab) and one

customized database table say DB

I fill itab and then deletes the existing records in table DB and now i have to fill DB with records in table

itab .

I have two optins :

LOOP AT ITAB. modify db from itab . Endloop .

OR

MODIFY DB FROM TABLE ITAB .

which one is better(performace wise) and should i write commit work after

these statements .

Thanks in Advance .

8 REPLIES 8
Read only

gopi_narendra
Active Contributor
0 Likes
780

u can just use the modify statement and no need to write any commit after that

modify ZTABLE from table ITAB.

**make sure the internal table ITAB is of type ZTABLE**

<b><b>PLEASE CLOSE ALL THE PREVIOUS THREADS IF PROBLEM SOLVED</b></b>

Regards

Gopi

Message was edited by: Gopi Narendra

Read only

former_member186741
Active Contributor
0 Likes
780

I believe the 2nd option (from table) is better and that no commit is required. An implicit commit will occur when your program ends..... of course if you have a complex program you may need to put one in but for normal purposes it's not needed.

If your table is small or medium the performance benefits may be small so if you wanted to, say, catch errors and show them on a report for update failures then the first option would be ok.

Read only

Former Member
0 Likes
780

Hi,

The second option is better performance wise. No need to write COMMIT WORK .

Best regards,

Prashant

Read only

Former Member
0 Likes
780

Hello,

Go for,

MODIFY DB FROM TABLE ITAB .

Because, if the internal table entries are not in DB then the DB will be inserted with those table entries, Otherwise, the record will be modified against internal table.

Performance is also good because, you are accessing the DB at once and not in loop.

Regs,

Venkat

Message was edited by: Venkat Ramanan Natarajan

Read only

Former Member
0 Likes
780

hi,

Most of the performance issues are related to database. It should be an inherent practice to reduce the access to database as far as possible and use it in the most optimal manner.

Just as in select statements, database updates also affect the performance. When records are to be inserted in database table do it in once. Populate the internal table completely, with which the records are to be inserted. Then update the table from the internal table instead of updating it for each record within the loop.

Do not use

	Loop at i_mara.
		---------------
		---------------
		mara = i_mara.
Modify mara.
	Endloop.

Avoid accessing database multiple times even for updating the records.

As is seen the table mara is modified for each record. The performance can be considerably improved if the internal table is populated and then the table is updated once for all the records.

Instead use the statement

Loop at i_mara.
--------------
---------------	
Modify i_mara.
Endloop.

Modify mara from table i_mara.

As is seen the table mara is modified for once in the end. The performance is considerably improved and the database access is reduced.

Regards,

Sailaja.

Read only

Former Member
0 Likes
780

Hi,

1) modify db from table itab will be better for

performance wise because database will be accessed

once per all table entries where as in

2)

loop at itab.

endloop.

database is hit for each record and it may take

time because of network activity .

use option 1 and use commit work after modify statement

so the changes are reflected in database

Regards

amole

Read only

Former Member
0 Likes
780

Hi ,

modify db from table itab will be better for

performance wise because database will be accessed

once per all table entries where as in

loop at itab.

endloop.

database is hit for each record and it makes performance poor.

use <b>modify db from table</b> ...

need not use commit work...also no prob if u use commit work/

if u use commit work..the modification is reflected immediately in the table..as the execution is passed through the commit statement.

if u dont use ...then it reflected to table only at the end of execution of program,.

Regards,

Ajith

Read only

anversha_s
Active Contributor
0 Likes
780

hi,

dont write the select or othere data base queries inside the loop.

it will affect the performace badly.

so use MODIFY DB FROM TABLE ITAB .

rgds

anver

pls mark all hlpful anwers