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

Reg:Delete

Former Member
0 Likes
891

Hi all,

I have retrived data from an DB table.From the retrieved entreis deleted entries where werks not in Plant on the screen.

for this i have used the code

delete itab where werks ne s_werks.

is this the corect code.Bcoz even though werks = s_werks the data from itab is gettin deleted.

here s_werks is a select-option field.

regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
862

Hi Ganesh,

It is wrong.

delete itab where werks not in s_werks. is correct.

Regards,

Ravi

8 REPLIES 8
Read only

Former Member
0 Likes
863

Hi Ganesh,

It is wrong.

delete itab where werks not in s_werks. is correct.

Regards,

Ravi

Read only

0 Likes
862

Hi Ravi,

I have 2 db tables and based on particular conditions i am retriving data into these 2 internal tables.The selection-screen contains fields date,werks as a range.if i give only one valu in the date ie. 09/04/2006 the data preior to this date is also retrieved how does this happen.Plz clarify

regards

Read only

0 Likes
862

Hi Ganesh,

Can you show the select statement?

If your select statement has something like this:

where date <= s_date-low.

Then it would get all the dates before that.

REgards,

ravi

Read only

0 Likes
862

No the select stm is not like tht it is as follows

select zchangedt zlocid matnr werks from db table into corresponding fields of itab2 for all entries in itab1 where ZCYLBARCD = ITAB1-BARCD.

IF SY-SUBRC = 0.

delete int_ITAB2 where not werks in s_werks[].

ENDIF.

Read only

0 Likes
862

Hi ganesh,

As you can see, the where clause itself doesn't filter the data based on the date you enter in the selection screen.

Just entering some date in the selection screen doesn't filter the data.YOur select should have the where condition based on that date as well.

select zchangedt zlocid matnr werks from db table into corresponding fields of itab2 for all entries in itab1 where ZCYLBARCD = ITAB1-BARCD

<b> and zchangedt in s_date.</b>

Make the highlighted change.

Regards,

ravi

Read only

Former Member
0 Likes
862

hi Ganesh,

Declare it in this way in your select statement ..

i.e,

select *

where werks <b>in </b> s_werks

and delete statement should be

<b>delete it_marc where werks not in s_werks. </b>

Regards,

Santosh

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
862

Hi,

If possible,it is better to take needed records.So if possible,

select the records from db table which is given in screen.

select * from marc into table itab where werks in s_werks.

Otherwise,the code should be

data itab type standard table of marc.

tables marc.

select-options s_werks for marc-werks.

select * from marc into table itab.

delete itab where not werks in s_werks.

sort itab by werks.

Kindly reward points by clicking the star on the left of reply,if it helps as per SDN policy.

Read only

Former Member
0 Likes
862

Hi,

delete itab where werks ne s_werks.

change to

<b>delete itab where not werks in s_werks.</b>

Regards

amole