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

Using Delete .. WHERE .. statement on dynamic internal tables

Former Member
0 Likes
1,821

Hi Experts,

We are having a requirement to delete some selected Mgmt Unit’s(MU) from an internal table by passing this table to an FM as a parameter.

Since the structure of the internal table will not be known at run time within the FM, we are using field symbols to check the value of MU and delete the record in internal table by looping on it.  The issue here is this process needs to be done by looping on SOURCE_PACKAGE record by record.

We felt it would be performance intensive to loop on source package and delete record by record in source_package table.  Instead we were checking out options to use DELETE internal table where MU = “XXX” to delete the selected records at a time instead of looping source package.

When we tried using DELETE statement along with where clause it throws an error saying Line type should be declared as static structure, since internal table is having dynamic structure.

Do you have any suggestion to avoid looping on source package inside FM for dynamic structures to delete the selected management units?

Thanks,

Vijay

3 REPLIES 3
Read only

Former Member
0 Likes
1,014

ABAP is able to read the lines in a dynamic table like this:

READ TABLE <lt_tab> with key ('ID') = lv_value assigning <ls_row>.

I'm not sure if this works with where clause in a loop, you can try. If this does not work, then you can create a do-enddo cycle with reading like written and if sy-subrc = 0 deleting the sy-tabix.

But as for performance, this does not have to be a better solution than your first (e.g. when number of rows to be deleted is large).

Read only

0 Likes
1,014

Hi Joseph,

Thanks for your reply.

I am looking for some way to avoid this loop to delete data on dynamic structure.

Like using Delete IT_TAB where ('MGMT_UNIT') = 'XYZ'.

currently this is not working since the IT_TAB table type is not static.

Read only

0 Likes
1,014

as abap help statements explains:

The dynamic specification of components using character-type data objects in parentheses is not supported here.

So you will not have any other way than looping the table.