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

Filter internal table with select-options

Former Member
0 Likes
3,324

Hi Everybody,

The issue is with select options. Following is the structure of my internal table. I have to delete the data from itab based on select options selections. It is not behaving the way I expected. It is not filetering all entires. I have tried declaring the table of type hashed with key. Not getting how select option works in the where condition of internal table. Please suggest.

TYPES:BEGIN OF t_data,

kunnr TYPE kna1-kunnr,

tdline TYPE tline-tdline,

END OF t_data.

DATA: it_tmp TYPE STANDARD TABLE OF t_data,

wa_tmp TYPE t_data.

SELECT-OPTIONS: s_tdline for tline-tdline.

DELETE it_tmp WHERE tdline not in s_tdline.

Thanks,

Rajani

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,051

May sound silly.

Change the position of NOT before the field in the where of the delete statement


TYPES:BEGIN OF t_data,
kunnr TYPE kna1-kunnr,
tdline TYPE tline-tdline,
END OF t_data.

DATA: it_tmp TYPE STANDARD TABLE OF t_data,
wa_tmp TYPE t_data.

SELECT-OPTIONS: s_tdline for tline-tdline.

DELETE it_tmp WHERE NOT tdline in s_tdline.

Vikranth

13 REPLIES 13
Read only

Former Member
0 Likes
2,051

DELETE it_tmp WHERE (tdline <> s_tdline-low and tdline <> s_tdline-high).

Read only

Former Member
0 Likes
2,052

May sound silly.

Change the position of NOT before the field in the where of the delete statement


TYPES:BEGIN OF t_data,
kunnr TYPE kna1-kunnr,
tdline TYPE tline-tdline,
END OF t_data.

DATA: it_tmp TYPE STANDARD TABLE OF t_data,
wa_tmp TYPE t_data.

SELECT-OPTIONS: s_tdline for tline-tdline.

DELETE it_tmp WHERE NOT tdline in s_tdline.

Vikranth

Read only

0 Likes
2,051

Hey Vikranth,

It might sounded silly but solved my problem .Sometimes tend to do silly mistakes you see, Thanks a lot.

Regards,

Rajani.

Read only

0 Likes
2,051

Was it my suggestion that solved your question?

Read only

0 Likes
2,051

Yes. It is your suggestion that solved my problem.

"Changing the position of NOT before the field in the where of the delete statement".

Rajani.

Read only

Former Member
0 Likes
2,051

rajni,

i dont think there is much error in your code..

just change

SELECT-OPTIONS: s_tdline for tline-tdline.

to

SELECT-OPTIONS: s_tdline for wa_tmp-tdline.

and try..

and keep a debugger in that line..... and see the value in table and in the select option.. compare themm

Read only

0 Likes
2,051

Hi Soumyapraksh,

Thanks for reply. Your suggestion is working as well. I just tried it. No need to change the position of NOT with the following declaration.

SELECT-OPTIONS: s_tdline for wa_tmp-tdline.

DELETE it_tmp WHERE tdline NOT IN s_tdline.

Rajani.

Read only

Former Member
0 Likes
2,051

Hi Rajani,

wrong syntax in the code.

DELETE it_tmp WHERE not tdline in s_tdline.

in your syntax, s_tdline represents the header not the body.

add the [] to the selection option so the body of the internal table is considered and your problem will be fixed.

refer to the correct syntax given below.

DELETE it_tmp WHERE not tdline in s_tdline[].

Regards,

Phani.

Read only

ThomasZloch
Active Contributor
0 Likes
2,051

> DELETE it_tmp WHERE tdline not in s_tdline.

This is the correct syntax according to ABAP documentation. Please give a specific example for contents of it_tmp (before and after the deletion) and s_tdline for a case that does not work as expected.

Thomas

Read only

0 Likes
2,051

Hello Thomas,

When i try to use


DELETE it_tmp WHERE tdline not in s_tdline.

I get a syntax error

Field "IN" is unknown. It is neither in one of the specified tables nor defined by a "DATA" statement.

Whereas when i change it to


DELETE it_tmp WHERE NOT tdline in s_tdline.

Its working fine.

Am on version 4.6 C. Not sure if this is version dependent

Vikranth

Read only

0 Likes
2,051

Hi Vikranth,

It is not giving error if the statement is ,

DELETE it_tmp WHERE tdline not in s_tdline. on ECC 5.0

Rajani.

Read only

0 Likes
2,051

Hello Rajani,

Thanks for letting me know that. Looks like the usage of NOT varies with different versions.

Vikranth

Read only

0 Likes
2,051

It was introduced for release 6.10:

http://help.sap.com/abapdocu_70/en/ABENNEWS-610-OTHERS.htm#!ABAP_MODIFICATION_3@3@

Once again this highlights that anybody asking a question should briefly quote the version he is working on.

Thomas