‎2005 Nov 28 10:00 AM
I wrote the following piece of code:
<b> LOOP AT gt_rpm_project INTO ls_rpm_project
WHERE guid = ls_cgpl_project-guid
AND category = p_categ
AND subcategory IN p_subct.
ENDLOOP.</b>
where
gt_rpm_project is an internal table and
p_subct is a select option in the selection screen.this code gives an error mentioning <b>IN cannot be used</b>. Since it is a select -option i cannot use '=' or'between'(as p_subct apart from having a range can also have individual entries.)
Please advice how to go about this.
Thanks in advance!!
Saurabh
‎2005 Nov 28 10:03 AM
Because you are using a select option, I believe you would be having a database access before this query.
Why don't you filter the entries based on the select options that time itself. You wouldn't have to include a IN claus at all then.
Regards,
Vijay
‎2005 Nov 28 10:04 AM
you can also try
subcategory > selectoption-low AND subcategory < selectoption-high.
Regards.
‎2005 Nov 28 10:11 AM
should not be a problem. you should be able to use it. can you give us the exact error message?
to simulate your case i tried the following code and there was no syntax error.
data: itab type standard table of csks .
data: wa like line of itab .
select-options: p_dt for sy-datum .
loop at itab into wa where kokrs = '9999' and datab in p_dt .
endloop .
Regards
Raja
‎2005 Nov 28 5:19 PM
The simplest way would be to remove the subcategory field from the where condition and write an IF condition inside the Loop . IF SY-SUBRC = 0 then move the values from the internal table gt_rpm_project into ls_rpm_project.
LOOP AT gt_rpm_project
WHERE guid = ls_cgpl_project-guid
AND category = p_categ.
IF gt_rpm_project-subcategory IN p_subct.
ls_rpm_project = gt_rpm_project.
append ls_rpm_project.
ENDIF.
ENDLOOP.
‎2005 Nov 28 5:33 PM
Hi,
Could u please let us know what is the exact error message, because the code u have posted looks perfectly alright to me, only possiblity would be that p_subct is not declared as select option which u have mentioned it has been declared, can u post the complete code with the variables declaration..
‎2005 Nov 28 5:37 PM
the only reason that I can see to your erro is, Your field p_subct is a parameter, and not a select-options.
Or it's anything different from a value range.
Alexandre Nogueira.
‎2005 Nov 28 5:37 PM
This works OK:
REPORT ztest.
DATA: BEGIN OF gt_rpm_project OCCURS 0,
guid,
category,
subcategory,
END OF gt_rpm_project,
BEGIN OF ls_rpm_project.
INCLUDE STRUCTURE gt_rpm_project.
DATA: END OF ls_rpm_project,
ls_cgpl_project LIKE ls_rpm_project.
DATA: p_categ.
RANGES p_subct FOR gt_rpm_project-subcategory.
LOOP AT gt_rpm_project INTO ls_rpm_project
WHERE guid = ls_cgpl_project-guid
AND category = p_categ
AND subcategory IN p_subct.
ENDLOOP.What version are you on?
Rob