2

I've had a dump recently,

DATA: gt_data    TYPE SORTED TABLE OF ty_data WITH NON-UNIQUE KEY bukrs gaapnm,
     ...
     lt_tabdel  TYPE standard TABLE OF ty_data.

  LOOP AT gt_data ASSIGNING <gf_data>.
    IF <gf_data>-KANSW + <gf_data>-KAUFW = 0.
      APPEND <gf_data> TO lt_tabdel.
    ENDIF.
  ENDLOOP.

  IF lt_tabdel IS NOT INITIAL.
    DELETE gt_data FROM lt_tabdel.
  ENDIF.

And on the line with deleting table from internal table - i've had a dump: In statement Convert object to integer only numerical type data objects are supported at argument position "object". In the present case, operand "object" has the non-numerical data type "TABLE OF TY_DATA". I just can't understand - why? Both of it had the same type... So, it will be great if you could provide some advice and a bit of explanation of error origins.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
AlexanderK
  • 365
  • 7
  • 21

3 Answers3

5

You have (inadvertently) used this variant of the DELETE statement that uses FROM and TO to specify indexes, i. e. numbers of table lines. In a sense, you are coding delete all lines in gt_data below the one identified by the line number in lt_tabdel, and the system goes belly-up when trying to convert the contents of lt_tabdel to an integer.

As far as I can see - i. E. if you've provided a complete code sample - this should be sufficient:

LOOP AT gt_data ASSIGNING <gf_data>.
  IF <gf_data>-KANSW + <gf_data>-KAUFW = 0.
    DELETE gt_data.
    CONTINUE. " safety measure
  ENDIF.
ENDLOOP.

For an explanation of the CONTINUE statement, check this answer.

Suncatcher
  • 10,355
  • 10
  • 52
  • 90
vwegert
  • 18,371
  • 3
  • 37
  • 55
  • And if i want to delete all content from the table, that presented in another one, what should i use in that case? – AlexanderK Feb 08 '16 at 09:35
  • Why are you using a separate loop in the first place? – vwegert Feb 08 '16 at 09:40
  • May be there's need in new checks arises, and i suppose that existing table is too large to delete rows within loop. So, to evade additional load on servers - i prefer to fill additional table and delete it from previous main table later. So, separate loop was just a first idea that i had in mind. If there's a better way to do it - i'm all in. – AlexanderK Feb 08 '16 at 10:05
  • You're not making sense there. If you need to remove the line, delete it. If you need multiple conditions, implement them. – vwegert Feb 08 '16 at 11:45
0
IF lt_tabdel IS NOT INITIAL.
DELETE gt_data FROM lt_tabdel.
ENDIF.

* IF lt_tabdel IS NOT INITIAL.
DELETE TABLE gt_data FROM lt_tabdel.
ENDIF. *

Adding TABLE will help you.

A A
  • 1
-1

Ok, i found solution. Delete - was the wrong command. So i used this one instead:

LOOP AT gt_data ASSIGNING <gf_data>.
    IF <gf_data>-KANSW + <gf_data>-KAUFW <> 0.
      append <gf_data> to lt_data.
    ENDIF.
  ENDLOOP.

  gt_data[] = lt_data[].

Just filled another table and assigned it contents to the main table.

AlexanderK
  • 365
  • 7
  • 21