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

deleting rows

Former Member
0 Likes
1,053

i am using the code to delete rows from internal table that are not having any values in this particular field. but it is giving an dump.

what is wrong here?

loop at t_data7 into wa_data7.

if wa_data7-total_turnover eq 0

AND wa_data7-total_current eq 0

AND wa_data7-total_current1 eq 0

AND wa_data7-total_current2 eq 0

AND wa_data7-total_current3 eq 0

AND wa_data7-total_current4 eq 0

AND wa_data7-total_current5 eq 0.

DELETE t_data7 from wa_data7.

clear wa_data7.

else.

wa_turnover = wa_data7.

append wa_turnover to t_turnover.

endif.

endloop.

8 REPLIES 8
Read only

Former Member
0 Likes
1,019

Hi

Insted of DELETE t_data7 from wa_data7.

Use

DELETE table t_data7 from wa_data7.

or

DELETE t_data7 index sy-tabix.

Regards

Aditya

Read only

Former Member
0 Likes
1,019

Loop at t_data into wa_Data.

v_index = sy-tabix.

if t_data----- is initial.

delete t_Data index v_index.

endif.

endloop.

Use this coding to delete the records from internal table.

Read only

Former Member
0 Likes
1,019

Hi,

Modify the statement,

DELETE t_data7 from wa_data7.

as,

Delete t_data7 index sy-tabix.

Your code should work fine.

Reward if helpful.

Regards.

Read only

Former Member
0 Likes
1,019

Hi,

Use table in the DELETE statement and it will work.

loop at t_data7 into wa_data7.

if wa_data7-total_turnover eq 0

AND wa_data7-total_current eq 0

AND wa_data7-total_current1 eq 0

AND wa_data7-total_current2 eq 0

AND wa_data7-total_current3 eq 0

AND wa_data7-total_current4 eq 0

AND wa_data7-total_current5 eq 0.

DELETE table t_data7 from wa_data7.

clear wa_data7.

else.

wa_turnover = wa_data7.

append wa_turnover to t_turnover.

endif.

endloop.

mark all helpful answers.

Read only

Former Member
0 Likes
1,019

Try using DELETE TABLE t_data7 from wa_data7.

As per SAP documentation,

DELETE dbtab .

Effect:

For dbtab, a database table defined in the ABAP Dictionary or a view defined in the ABAP Dictionary can be specified.

Only views that refer to a single database table, and whose maintenance status in the ABAP Dictionary permits change access can be specified.

DELETE itab FROM idx1.

Effect

If you specify FROM, all the table rows from the table index idx1 onwards are included. idx1 must be a data object with type i. If the value of idx1 is less than or equal to 0, a runtime error occurs. If the value is greater than the number of table rows, no rows are deleted.

Hope this helps.

Thanks,

Balaji

Read only

Former Member
0 Likes
1,019

Hi,

Use Keyword IS INITIAL this means the entries are null

Try...

if wa_data7-total_turnover is initial.

-


-


,....................

endif..

Regards,

kavitha

Read only

Former Member
0 Likes
1,019

Hi,

You can use below and for better performance.


delete t_data7 where total_turnover eq 0
                             AND total_current eq 0
                             AND total_current1 eq 0
                             AND total_current2 eq 0
                             AND total_current3 eq 0
                             AND total_current4 eq 0
                             AND total_current5 eq 0.

t_turnover [] = t_data7 [].

Thanks,

Sriram Ponna.

Edited by: Sriram Ponna on Mar 11, 2008 12:24 PM

Read only

Former Member
0 Likes
1,019

Hi

try like this

DELETE t_data7[] where total_turnover eq 0

AND total_current1 eq 0

AND total_current2 eq 0

AND total_current3 eq 0

AND total_current4 eq 0

AND total_current5 eq 0.

it_turtnover[] = t_data7[]

this will much faster than loop

try this

Regards

Shiva

Edited by: Shivakumar Hosaganiger on Mar 11, 2008 12:01 PM