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

I cannot delete multiple entries from table

bhat_vaidya2
Active Participant
0 Likes
500

Hi

i am trying to delete multiple entries from table while keeping some data.

for example I have the following table

Plant Item

US101 777

US101 888

US101 999

US101 666

I want to keep the rows where the item is 777 and 888 for plant US101 and keep delete the rest data

I wrote the following code

Delete source_package where Plant = 'US101' and Item NE '777' or '888'.

but all the rows get deleted.

I tried deleting single row and it worked.

Delete source_package where Plant = 'US101' and Item NE '777' .

How can I delete multiple rows.

thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
434

Delete source_package where Plant = 'US101' and Item NE '777' and '888'.

(use 'AND' instead of 'OR' for selecting item).

Edited by: vijetasap on May 3, 2010 10:33 AM

2 REPLIES 2
Read only

Former Member
0 Likes
435

Delete source_package where Plant = 'US101' and Item NE '777' and '888'.

(use 'AND' instead of 'OR' for selecting item).

Edited by: vijetasap on May 3, 2010 10:33 AM

Read only

Former Member
0 Likes
434

Hi Bhat Vaidya,

Plz refer the following code.. IT will solve ur problem..

REPORT  ZSDN_TEST.
data: BEGIN OF it_data OCCURS 10,
        plant(4),
        item_num TYPE string,
      END OF it_data.
data: str type string.

data: it_final like it_data OCCURS 10 WITH HEADER LINE.

it_data-plant = 'US01'. it_Data-item_num = 777.  append it_data.
it_data-plant = 'US01'. it_Data-item_num = 888.  append it_data.
it_data-plant = 'US01'. it_Data-item_num = 999.  append it_data.
it_data-plant = 'US01'. it_Data-item_num = 666.  append it_data.

delete it_data where plant = 'US01' and item_num ne 777 and item_num ne 888.

LOOP AT it_data.
write:it_data-plant,it_data-item_num.
skip.
ENDLOOP.

Regards,

Apoorv