Application Development 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: 

Delete from internal table based on records in another internal table.

Former Member
0 Kudos

Hello Everyone,

Please excuse me if i am posting in the wrong forum. But, i think that this is more related to ABAP in general.

I am trying to improve the performance of a piece of my code. I would like to know if the following scenario is possible without looping.

I have an internal table (ITAB1) having fields A, B. And i have another internal table (ITAB2) having fields B, C.

A is the key for ITAB1 and B is the key for ITAB2.

I have already populated the table ITAB2 with filtered values using select. ITAB1 contains all entries of a table.

Is it possible for me to delete records from ITAB1 such that ITAB1-B eq ITAB2-B?? (without using a loop statement)

That is, is it possible for me to delete all irrelevant records from ITAB1 such that i have only records in ITAB1 which satisfy the condition ITAB1-B eq ITAB2-B in a single statement without using loops?

Please Help. Let me know if you need more clarity.

Thanks in Advance,

Mz

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hai Mazin,

Not possible without using loop.

The oly way is while selecting/fetching data you can take some precautions.

1. First populate itab2.

2. then in select query for itab1 use "FOR ALL ENTRIES IN ita2" in where condition you can give your usualy conditions along with the for all entry addition a = itab2-b.

This will surely improve your pograms perofrmance.

Hope the discussion would be helpful.

Cheers,

Suvendu

8 REPLIES 8

former_member212005
Active Contributor

What you can do...is while populating ITAB2...you can put the data of the field 'B' in a selection table (i.e. range)

and then use the delete statement as..

DELETE itab1 WHERE b in r_b.

Hope it helps!

0 Kudos

first select the ITAB2 values and then fill in ITAB1 with ur requirement checking the entry in ITAB1.

Former Member
0 Kudos

Thanks for the quick response.

@vin

Could you please be a bit more specific about ranges. I am using a class and I am not alowed to use ranges statement in the class.

@Soumya

i am selecting data into ITAB2 manually (select A, B into ITAB2 from [table name] where [condition] )

But, ITAB1 is already passed to me as a parameter. I cannot change the way that it is populated initially.

Thanks

Mz.

0 Kudos

I doubt whether you can avoid Loop then...

0 Kudos

You have to Loop at itab2 at least once if you cannot use ranges.

0 Kudos

Hi,

Select the fields you need

into table itab2

from table

for all entries in itab1.

You can then move the values of the field 'B' to another internal table...

Delete from itab2 for the values present in this intab created./.

Former Member
0 Kudos

Hai Mazin,

Not possible without using loop.

The oly way is while selecting/fetching data you can take some precautions.

1. First populate itab2.

2. then in select query for itab1 use "FOR ALL ENTRIES IN ita2" in where condition you can give your usualy conditions along with the for all entry addition a = itab2-b.

This will surely improve your pograms perofrmance.

Hope the discussion would be helpful.

Cheers,

Suvendu

p244500
Active Contributor
0 Kudos

hi

you can use this command

SELECT * FROM VBAK

APPENDING TABLE IT_VBAK

FOR ALL ENTRIES IN IT_VBRP

WHERE VBELN EQ IT_VBRP-VGBEL.

regard,

nawa