‎2009 Nov 10 10:02 AM
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
‎2009 Nov 10 10:22 AM
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
‎2009 Nov 10 10:08 AM
DELETE it_tmp WHERE (tdline <> s_tdline-low and tdline <> s_tdline-high).
‎2009 Nov 10 10:22 AM
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
‎2009 Nov 10 11:32 AM
Hey Vikranth,
It might sounded silly but solved my problem .Sometimes tend to do silly mistakes you see, Thanks a lot.
Regards,
Rajani.
‎2009 Nov 10 11:37 AM
‎2009 Nov 10 11:40 AM
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.
‎2009 Nov 10 10:29 AM
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
‎2009 Nov 10 11:50 AM
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.
‎2009 Nov 10 10:45 AM
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.
‎2009 Nov 10 10:56 AM
> 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
‎2009 Nov 10 11:31 AM
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
‎2009 Nov 10 11:38 AM
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.
‎2009 Nov 10 11:40 AM
Hello Rajani,
Thanks for letting me know that. Looks like the usage of NOT varies with different versions.
Vikranth
‎2009 Nov 10 11:50 AM
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