cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Query Generator - Allow multiple values for a parameter

03-29-2022 9:24 PM
n3oalonso Explorer
2986 views 5 comments
0 Likes
SAP Managed Tags
Subscribe

Hi All,

I need the user to be able to select multiple classes of item when prompted using the query manager. Should be the equivalent of “allow multiple values” property for a parameter in Crystal Report. I tried this, but it's not working:

SELECT TOP 10 *

FROM OITM T0

WHERE T0.ItmsGrpCod IN ('[%0]')

Any idea???

TIA

0 Likes

Accepted Solutions (0)

Answers (2)

Answers (2)

Johan_Hakkesteegt
Active Contributor

Hi,

This can only be done easily if you predetermine the number of parameters:

SELECT TOP 10 *
FROM OITM T0
WHERE T0.ItmsGrpCod IN ('[%0]','[%1]','[%2]')

You would need to prepare the maximum number of parameters that you think you will ever be using, but you do not need to use them all when you run the query:

Regards,

Johan

n3oalonso
Explorer
0 Likes

Hi Johan,

Thank for your answer. This will work in some scenarios, but in others I think it would be difficult to manage 7 or 8 parameters in the “selection criteria” window. After some talks, we will go with a crystal report for this case.

Best regards,

Luis

Johan_Hakkesteegt
Active Contributor
0 Likes

Hi Luis,

One other option is to use a User Defined Table, to hold the parameter values. You would then just have to change the values in the table before you run the query:

SELECT TOP 10 *
FROM OITM T0
WHERE T0.ItmsGrpCod IN (select FieldWithParameterValues from UserDefinedTable)

Regards,

Johan

former_member4944
Participant

Hi n3oalonso,

Try This Query

In Query Generator...,

/*SELECT FROM [dbo].[OITM] T0*/
declare  @ItmsGrpCod AS Varchar(50)
/* WHERE */
set @ItmsGrpCod =/* T0.ItmsGrpCod */ '[%0]'
Select Top 10* From OITM T0
Where T0.ItmsGrpCod=@ItmsGrpCod or @ItmsGrpCod=''

Thanks and Regards,

Abdul Basith

n3oalonso
Explorer

Thank for your answer. Very interesting.

In this case what we were trying to do is more like a list of values in the filter condition.

Is there a documentation for this feature in SAP?

Really appreciated.

Best regards,

Luis