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

Query on Internal Table

Former Member
0 Likes
837

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
806

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

6 REPLIES 6
Read only

alejandro_bindi
Active Contributor
0 Likes
806

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.

Read only

Former Member
0 Likes
807

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

Read only

Former Member
0 Likes
806

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

Read only

Former Member
0 Likes
806
Read only

Former Member
0 Likes
806

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

Read only

varma_narayana
Active Contributor
0 Likes
806

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>