2008 Mar 19 5:23 AM
Want to know the difference between the two modifying statements..Please explain me what is exactlyhappening in the both the logics?
LOOP AT ITAB INTO WA.
I = SY-TABIX MOD 2.
IF I = 0.
WA-FLAG = 'X'.
MODIFY ITAB FROM WA.
ENDIF.
ENDLOOP.
-
LOOP AT ITAB ASSIGNING <WA>.
I = SY-TABIX MOD 2.
IF I = 0.
<WA>-FLAG = 'X'.
ENDIF.
ENDLOOP.
2008 Mar 19 5:30 AM
Hi,
In first statement.
WA-FLAG = 'X'.
MODIFY ITAB FROM WA.
whatever the data is there in WA taht data will ov write in internal table.
IN second statement:
<WA> -
is Field symble .Which is used to assign the data eventhough we don't know the incoming structure.(This is dynamic)
<WA>-FLAG = 'X'.
Here you are not changing the internal table ITAB data.
2008 Mar 19 5:33 AM
Hi Saswat,
Logically they both achieve the same result except 1st option is slower than the second.
LOOP AT ITAB INTO WA.
I = SY-TABIX MOD 2.
IF I = 0.
WA-FLAG = 'X'.
MODIFY ITAB FROM WA.
ENDIF.
ENDLOOP.
Here the data is copied in work area then is modified from the work area to the internal table.
When you do it in loops the current line of the loop pass is modified.
The overhead is to copy the data from internal table to the work area and then from the work area back to the internal table.
-
LOOP AT ITAB ASSIGNING <WA>.
I = SY-TABIX MOD 2.
IF I = 0.
<WA>-FLAG = 'X'.
ENDIF.
ENDLOOP.
In this case when it is looping through the internal table the field symbol has a reference to the line of the internal table that is being currently processed and therefore the data is directly updated to the internal table and saves the overhead of copying over the data to and from the work area.
regards,
Advait.
2008 Mar 19 5:41 AM
Hi Saswant,
the first one rewrites the whole record of the internal table,
while the second one with field symbol overwrites only the field FLAG.
If u use modify statement with 'Transporting' addition then only those fileds which we use with 'Transporting' will be changed.
Cheers,
Balaji