Skip to Content
avatar image
Former Member

Delete dynamic table with dynamic range - problem

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

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • Jul 02, 2010 at 03:14 PM

    Cant we restrict it from the select query itself ?

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 02, 2010 at 03:23 PM

    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 ).

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • Jul 02, 2010 at 03:44 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • >

      > 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

  • avatar image
    Former Member
    Sep 21, 2010 at 03:07 PM

    hi jaime,

    i got the same problem. did u solve it?

    martin

    Add comment
    10|10000 characters needed characters exceeded