‎2007 Jun 21 2:59 PM
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
‎2007 Jun 21 3:26 PM
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
‎2007 Jun 21 3:04 PM
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.
‎2007 Jun 21 3:05 PM
Hello,
Try like this.
adr3_tab-chngind = charnull.
modify adr3_tab TRANSPORTING chngind where chngind is initial.
REgards,
Vasanth
‎2007 Jun 21 3:26 PM
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
‎2007 Jun 21 3:46 PM
Peter Inotai
Since I have millions(nearly 20 m) of Records on the Internal Table, will the LOOP AT again cause problem ?
Thanks
‎2007 Jun 21 3:50 PM
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
‎2007 Jun 21 3:51 PM
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.
‎2007 Jun 21 3:56 PM
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
‎2007 Jun 21 4:04 PM
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
‎2007 Jun 21 4:14 PM
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
‎2007 Jun 22 10:37 AM
‎2007 Jun 22 10:42 AM
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
‎2007 Jun 22 10:43 AM
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.