‎2008 Jun 09 11:43 AM
Hi ,
I have a dynamic table ( a field symbol reference) , and i want to delete some entries from it . How can i do that.
for example a table is <lt_abc>.
Now i want to delete from this table all entries whcih are not having minimum one entry in table X.
Regards
Anuj
‎2008 Jun 09 1:29 PM
hi,
hope this help.
LOOP AT <table> INTO <s_table> .
assign component 'MATNR' of structure <s_table> to <f_1> .
SELECT SINGLE * FROM MARA
WHERE MATNR = <f_1> .
if sy-subrc <> 0.
LOOP AT <table> INTO <s_table2> .
assign component 'MATNR' of structure <s_table2> to <f_2> .
CHECK <f_1> = <f_2> .
DELETE <table> INDEX sy-tabix.
ENDLOOP.
endif.
ENDLOOP.
‎2008 Jun 09 3:00 PM
Hi Anuj
Just imagine that <lt_abc> has a field named 'ABC'.
U can use a statement like that :
DELETE <lt_abc> WHERE 'ABC' NOT IN RANGE_FOR_ABC.
Do not forget to write fieldname ABC between single commas.
And here range_for_abc is a range for field.
-
The result code will look like that :
"first fill range for the table X :
ranges : range_for_abc for x_table-abc.
loop at X_table.
range_for_abc-sign = 'I'.
range_for_abc-option = 'EQ'.
range_for_abc-low = X_table.
append range_for_abc.
endloop.
"than delete the records not in this range :
delete <lt_abc> where 'ABC' not in range_for_abc.
Hope it helps.