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

Performance Improvement on LOOP AT

Former Member
0 Likes
1,182

Hi all

Here is the snapshot from a program :

****************************************************************

constants: charnull(1) TYPE x VALUE '00'.

DATA: BEGIN OF adr3_tab OCCURS 0,

.....

.....

chngind(1) TYPE x,

END OF adr3_tab.

SELECT addrnumber persnumber date_from consnumber country flgdefault

fax_number fax_extens faxnr_long fax_group

INTO TABLE adr3_tab

FROM adr3.

LOOP AT adr3_tab.

adr3_tab-chngind = charnull.

MODIFY adr3_tab.

ENDLOOP.

**************************************************

Above Loop eats more CPU time !

How could we improve the performance ?

Any advice ?

Thanks

1 ACCEPTED SOLUTION
Read only

Peter_Inotai
Active Contributor
0 Likes
1,157

Try field symbol...something like this:

field-symbols: <lwa_adr3_tab> type ...

loop at adr3_tab assigning <lwa_adr3_tab>.
 <lwa_adr3_tab>-chngind = charnull.
* No need for modify!!!!
endloop.

This way nothing is copied from the internal table to the header line, so it will be faster.

Peter

12 REPLIES 12
Read only

Former Member
0 Likes
1,157

Hi

Try to use work area in ur internal table.

Performance Improvement on LOOP AT

Posted: Jun 21, 2007 7:29 PM

constants: charnull(1) TYPE x VALUE '00'.

DATA: BEGIN OF adr3_tab OCCURS 0,

.....

.....

chngind(1) TYPE x,

END OF adr3_tab.

Data: it_adr3 type standard table of adr3_tab,

wa_adr3 type adr3_tab.

SELECT addrnumber persnumber date_from consnumber country flgdefault

fax_number fax_extens faxnr_long fax_group

INTO TABLE it_adr3

FROM adr3.

LOOP AT it_adr3 into wa_adr3.

wa_adr3-chngind = charnull.

MODIFY it_adr3 from wa_adr3.

ENDLOOP.

Read only

Former Member
0 Likes
1,157

Hello,

Try like this.


adr3_tab-chngind = charnull.
modify adr3_tab TRANSPORTING chngind where chngind is initial.

REgards,

Vasanth

Read only

Peter_Inotai
Active Contributor
0 Likes
1,158

Try field symbol...something like this:

field-symbols: <lwa_adr3_tab> type ...

loop at adr3_tab assigning <lwa_adr3_tab>.
 <lwa_adr3_tab>-chngind = charnull.
* No need for modify!!!!
endloop.

This way nothing is copied from the internal table to the header line, so it will be faster.

Peter

Read only

0 Likes
1,157

Peter Inotai

Since I have millions(nearly 20 m) of Records on the Internal Table, will the LOOP AT again cause problem ?

Thanks

Read only

0 Likes
1,157

Hello Remo J,

Field symbols its the faster way to loop on an internal table.

You will have no problem for Peter´s proposal

Hope this helps

Gabriel

Read only

0 Likes
1,157

LOOP AT ITAB ASSIGNING <FS> cuts out the "copy cost" which occurs with LOOP AT ITAB INTO <WA> or LOOP AT ITAB (data is copied into the headre line here. For efficiency, field symbols should be used whenever possible.

Read only

0 Likes
1,157

Hi all

Why the following Stmt is not efficient when comparing Field-symbols:

<b> adr3_tab-chngind = charnull.

modify adr3_tab TRANSPORTING chngind where chngind is initial.</b>

Also it does not uses even LOOP AT !

I feel this stmt works for all record on a single time ! Please correct me if I am wrong.

Regards

Read only

0 Likes
1,157

Hi Remo,

Yes, You are corect.

modify adr3_tab TRANSPORTING chngind where chngind is initial. This statement does not need LOOP..ENDLOOP and will modify the reocrds which satisfies the condition.

Thanks,

Vinay

Read only

0 Likes
1,157

Hi all

Using the Field-symbols inside the LOOP, do I have clear its current content using clear stmt inside the LOOP!

loop at adr3_tab assigning <lwa_adr3_tab>.

<lwa_adr3_tab>-chngind = charnull.

  • No need for modify!!!!

<b>clear <lwa_adr3_tab>.</b>

endloop.

Is it required clear the content before the next loop contents gets pointed using FS ?

Regards

Read only

0 Likes
1,157

Any one !

RJ

Read only

0 Likes
1,157

hello Remo,

Field-symbols are the fastest way to operations on intarenal table,.

u should never use the clera statement for feilds symbols abecause it direclty work on the internal table body. unles and until if u want to clear the purticular record in the itab

Read only

0 Likes
1,157

Hi,

This is from documentation.So as far I know,since it is only pointing no need toclear.

In "LOOP AT itab ASSIGNING <fs>", the field symbol <fs> points to the selected entry, that is, the line is not copied into a work area. You cannot reassing the field symbol to another line of the table or another field within the loop.