‎2007 Aug 16 5:21 AM
What is differnece between Modify Internal Table and Modify internal Table With Where Clause????
tell me with example i want to use it like
LOOP AT ITAB.
MODIFY ITAB.
ENDLOOP
LOOP AT ITAB.
MOFIDY ITAB WHERE <SOME CONDITION>
ENDLOOP.
and similar in case with Delete Internal Table .
Is it good practice to put delete Itab Where condition in LOOP.
‎2007 Aug 16 6:24 AM
Hi Singh
if u are writeing where condition in a inside a loop there is no use y because u have control only on a pqaarticular record that is sy-tabix.
reward points to all helpful answers
kiran.M
‎2007 Aug 16 6:19 AM
When modifying or deleting within LOOP, you are implicitly deleting with index (as in MODIFY itab INDEX 1.
Internally the sentence uses sy-tabix which holds the current index for the loop.
So if the line you want to delete inside the loop is the line you're processing, then don't use DELETE/MODIFY ... WHERE as more than one line (including the one you're processing or not) may fulfill the condition.
Regards,
Please reward points if helpful.
‎2007 Aug 16 6:24 AM
Hi Singh
if u are writeing where condition in a inside a loop there is no use y because u have control only on a pqaarticular record that is sy-tabix.
reward points to all helpful answers
kiran.M
‎2007 Aug 16 6:26 AM
Hi,
modigy itab:
The system searches the internal table for the line whose table key corresponds to the key fields in wa.
but modift itab where <condition>:
this statement ll compare lines which satisfies the condition and then modify that line
regards,
Aparna
‎2007 Aug 16 6:27 AM
Go through this link for details:
http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb35eb358411d1829f0000e829fbfe/content.htm
Regards,
Aparna
‎2007 Aug 16 7:22 AM
Hi
LOOP AT ITAB.
<b>a = a+5</b>
MODIFY ITAB.
ENDLOOP
in the above case if there is a field like a which is get modified by adding 5 to it , it will get modify directly
LOOP AT ITAB.
MOFIDY ITAB WHERE <SOME CONDITION>
ENDLOOP.
in the above condition when ever that condition comes in the internal table loop
it modifies that record and move forword
<b>MODIFY</b>
if write MODIFY statement out of loop with giving any condition the program will genarate a SHORTDUMP,
when ever ur trying write MODIFY statement out of loop and u don't want to go program to shortdump then at that sitvation you have mention the condition for that modify
Like modify also DELETE works
there is no problem with the DELETE statement
it is good to practice DELETE
rewar if useful
‎2007 Aug 16 9:26 AM
Hi Navdeep.
**Observe the Differences below
If you want to Modify the records row by row using this below syntax
<b>For eg: To increment the Sal of each employee by 1000</b>
LOOP AT ITAB into wa.
wa-sal = wa-sal + 1000.
MODIFY ITAB from wa.
ENDLOOP.
To modify group of rows at a time based on a condition.
Here we use WHERE condition so it should not be in a Loop.
This is the correct method:
WA-CITY = 'MUMBAI'.
MOFIDY ITAB FROM WA WHERE CITY = 'BOMBAY'.
**Same rules are applicable incase of DELETE Also.
<b>Reward if Helpful</b>