06-15-2009 10:00 AM
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
06-15-2009 10:27 AM
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
06-15-2009 10:05 AM
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!
06-15-2009 10:16 AM
first select the ITAB2 values and then fill in ITAB1 with ur requirement checking the entry in ITAB1.
06-15-2009 10:20 AM
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.
06-15-2009 10:31 AM
06-15-2009 10:31 AM
You have to Loop at itab2 at least once if you cannot use ranges.
06-15-2009 12:15 PM
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./.
06-15-2009 10:27 AM
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
06-15-2009 10:42 AM
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