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

delete data from dynamic table

former_member196517
Contributor
0 Likes
573

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

2 REPLIES 2
Read only

Former Member
0 Likes
510

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.

Read only

Former Member
0 Likes
510

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.