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 dynamic table with dynamic range - problem

Former Member
0 Likes
2,558

Hi guys,

I've have a need do delete an uncertain number of entrys from a dynamic table.

* Dinamic tables
    create data ref_c type table of (tabname).
    assign ref_c->* to <fs_c>. 

try.
        select *  from (tabname) into table <fs_c>
                  where (lv_query1) .
      catch cx_sy_dynamic_osql_syntax.
    endtry.

so far no problem.

but the volume of data is huge and i've got an dynamic range

loop at <fs_c> assigning <fs_gc>.
      lv_index = sy-tabix.
      assign component 'FIELD' of structure <fs_gc> to <fs_del_caract>.
      if <fs_del_caract> in lr_range.
      move-corresponding <fs_gc> to ls_colectt.
      collect ls_colectt into lt_colectt.
      else.
        delete <fs_v> index lv_index.
      endif.
    endloop.

this code can take much time.

is there any any to delete dynamic using delete table and dynamic tables?

Regards

Jaime

8 REPLIES 8
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,502

Cant we restrict it from the select query itself ?

Read only

0 Likes
1,502

Hi Keshav,

Thats the root of the trouble it cant be in the select.

thazs

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,502

You can specify dynamic WHERE clause in the DELETE statement. Check this SAP online documentation for the same: [http://help.sap.com/abapdocu_70/en/ABAPDELETE_ITAB_LINES.htm#!ABAP_ADDITION_4@4@].

Try this:

DATA: V_COND TYPE STRING.

V_COND = 'FIELD NOT IN LR_RANGE'.

DELETE <FS_C> WHERE ( V_COND ).

Read only

Former Member
0 Likes
1,502

Hi Suhas,

I've tried that and it trows this error on activation

In "LOOP ... WHERE ..." the row type of the table must be statically defined .

Thanks

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,502

Hi,

delete <fs_tab> where <field> not in lr_range.

This is what Suhas meant.

your error comes because you are using dynamic wheer clause in the loop.

Read only

0 Likes
1,502

>

> your error comes because you are using dynamic wheer clause in the loop.

Dynamic WHERE condition in the LOOP statement is currently supported by SAP.

@OP: Which version of ABAP are you using ?

BR,

Suhas

Read only

Former Member
0 Likes
1,502

hi jaime,

i got the same problem. did u solve it?

martin

Read only

0 Likes
1,502

Hi,

with dinamic subroutine pool

[http://help.sap.com/saphelp_nw04/helpdata/en/9f/db999535c111d1829f0000e829fbfe/content.htm]

Hope it helps you

Regards

Jaime