10-10-2007 10:40 AM
how to delete a perticular record from internal table based on the record exits in an another internal table .
10-10-2007 10:44 AM
use delete statement for deleting the records...
e.g. loop at itab1 into wa-itab1.
read table itab2 with key fld1 = wa_itab1-fld1.
if sy-subrc eq 0.
delete table itab1 from wa_itab1.
endif.
endloop.
Message was edited by:
sharayu kumatkar
10-10-2007 10:44 AM
use delete statement for deleting the records...
e.g. loop at itab1 into wa-itab1.
read table itab2 with key fld1 = wa_itab1-fld1.
if sy-subrc eq 0.
delete table itab1 from wa_itab1.
endif.
endloop.
Message was edited by:
sharayu kumatkar
10-10-2007 10:44 AM
do you want to read an internal table 1 depending on a variable of an internal table 2, say
loop at itab1 into wa_tab1,
read itab2 into wa_tab2 with key = wa_tab1-field.
if sy-subrc <> 0.
delete wa_tab1 from itab1.
endif.
endloop.
basically a delete statement would do.
10-10-2007 10:44 AM
Hi,
TYPES: BEGIN OF NAMETAB_TYPE,
NAME(30) TYPE C,
END OF NAMETAB_TYPE.
DATA: NAMETAB TYPE STANDARD TABLE OF NAMETAB_TYPE WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 100.
...
DELETE NAMETAB FROM 5 TO 36 WHERE NAME eq 'ABC'.
Here abc is value of another internal table.
Assign points if useful.
10-10-2007 10:44 AM
Hi,
ABAP Coding:
DATA:
lt_table_1 TYPE TABLE OF xxx WITH HEADER LINE,
lt_table_2 TYPE TABLE OF xxx,
l_idx TYPE i.
LOOP AT lt_table_1.
l_idx = sy-tabix.
READ TABLE lt_table_2 WITH KEY ... TRANSPORTING NO FIELDS.
IF sy-subrc EQ 0.
* Entry exists in lt_table_2
DELETE lt_table_1 INDEX l_idx.
ENDIF.
ENDLOOP.
Regards, Joerg
10-10-2007 10:44 AM
Hi..
This is the Sample code.
Loop at Itab1 .
Delete ITAB2 where Field1 = Itab1-field1.
Endloop.
REWARD IF HELPFUL.
10-10-2007 10:45 AM
1. Create a range.
DATA: r_field TYPE RANGE OF table-field.
2. Loop on the reference table and save the value to the range you created.
loop at table.
r_field-sign = 'I'.
r_field-option = 'EQ'.
r_field-low = table-field.
APPEND r_field.
CLEAR r_field.
endloop.
3. Delete the value in your table existing in the range you created.
Delete itab where field in r_field.
You can also do a loop in the reference table and deleting every record in every iteration but the first one that i gave you is much more faster because you don't need to read the table inside the loop which is a factor when you're dealing with large amount of records.
10-10-2007 10:47 AM
don loop and delet from same table.. instead do like this.
loop at itab2.
read table itab1 with key itab1-value = itab2-value.
if sy-subrc EQ 0.
delete itab1.
endif.
endloop
10-10-2007 10:48 AM
Hi,
you can write logic for deleting records from the ITAB comparing ITAB1.
Put a Loop on ITAB.
then read table ITAB1....and compare.
then Delete ITAB on success of the read statement.
then Modify ITAB.
Endloop.
Best Regards,
Bhawani