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 table records

Former Member
0 Likes
424

Is it possible to loop through a table, examine each record and

delete the record if it meets a certain condition, all within the loop?

Like:

field-symbols <fs> like line of mytable.

loop at mytable assigning <fs>.

if <fs>-field_1 = someValue.

delete ......

endif.

endloop

1 ACCEPTED SOLUTION
Read only

former_member194669
Active Contributor
0 Likes
404

Hi,

For performance reasons do delete outside of the loop.


field-symbols <fs> like line of mytable.
loop at mytable assigning <fs>.
if <fs>-field_1 = someValue.
  append mytable_1
endif.
endloop

delete ......... from mytable_1

aRs

2 REPLIES 2
Read only

gopi_narendra
Active Contributor
0 Likes
404

You can not delete directly from standard SAP tables, there are some predefined tcodes or bapis or procedures to it.

If you are talking abt custom tables ie Z tables, you can do it by using the Delete statement.

Regards

Gopi

Read only

former_member194669
Active Contributor
0 Likes
405

Hi,

For performance reasons do delete outside of the loop.


field-symbols <fs> like line of mytable.
loop at mytable assigning <fs>.
if <fs>-field_1 = someValue.
  append mytable_1
endif.
endloop

delete ......... from mytable_1

aRs