Passing multivalue parameter to a subreport - sql

I'm having a problem when working with multivalue parameters between reports.
I have a main report in which I have defined a multivalue paramer, which I use to run a SQL query to populate its dataset. The parameter is used in the WHERE clause in the following way:
WHERE values IN (#parameter)
It's working fine and it retreives the expected data.
Then this main report passes this parameter to a subreport. The parameter is also defined as multivalue in the subreport and, as far as I can see in the parameter's dropdownlist it receives the values in the right way. Something like this: A, B, C
The thing is that the query that populates the subreport's dataset returns nothing.
It also has a WHERE clause defined as in the main report (which is already working)
WHERE values IN (#parameter)
If I run the query manually, hardcoding the values to something like this:
WHERE values IN ('A', 'B', 'C')
it works, but when I try to use the parameter it doesn't. So, somehow it's losing the format or the values in the way.
I tried this solution in the subreport's dataset definition, which was proposed in another thread:
=join(Parameters!<your param name>.Value,",")
But it doesn't work for me, the dataset is still empty.
Any ideas about what I'm missing?
Thanks! :)

This should "just work." Make sure that the Parameter in the subreport is set up as multivalue, and I usually use the exact same query as in the parent report to provide "Available Values."
Check that you are passing the entire parameter to the subreport: In subreport properties on the parent report, the parameter's value should read [#MyParamName] not <<Expr>>. If it reads as the latter, edit the expression and make sure it doesn't have a (0) at the end. but =Parameters!MyParamName.Value is correct, not =Parameters!MyParamName.Value(0)

Just created the report from scratch again and it worked. I must have forgotten something in the middle.
Anyway, just in case somebody needs it, the two parameters, the one in the main report and the one in the subreport , must be defined as multivalue.
Then in your query you should use IN in your WHERE clase, something like this:
WHERE field IN (#parameter)
And nothing else is needed. I didn't need to do the following:
=join(Parameters!<your param name>.Value,",")
It just worked for me

I think I know what you did, as I was drawn here by having the same problem.
The subreports were setup fine, but when entering the parameter binding in the parent report, the Value drop down did not offer my parameter, so I used expression builder to select it. This left the grey << Expr >> marker in the value and would only work when I had only one value selected from the list. When I replaced this with [#MyParam] it worked fine regardless of the number of values selected. When I had a look at the value expression builder had created a bit closer it had =Parameters!MyParam.Value(0). Removing the (0) also fixes it.

Related

Different parameter count in FORM and PERFORM

I am trying to add a formal parameter in the FORM and PERFORM in an existing code, as I will be need it the extra parameter in a new function that I have to call. The idea is that when executing the new code it keeps showing the error: Different parameter count in FORM and PERFORM (routine: CM_SHOW_CRC, number of formal parameters: 2, number of actual parameters: 3).
The code that I have for the form part is as follows:
FORM cm_show_crc
USING
civ_matnr TYPE matnr
civ_charg TYPE charg_d
civ_werks TYPE werks_d. "The parameter that I added
And the perform code is:
PERFORM cm_show_crc
USING
pis_sdow_alv-matnr
pis_sdow_alv-charg
pis_sdow_alv-werks. "The parameter that I added
The table pis_sdow_alv is type of a structure that also includes the variable WERK(Component type WERKS_D)
Before adding the new parameter WERK the code was working fine.
May anyone know what the problem in this part of the code may be?
There was also another similar question in: Different number of parameters in FORM and PERFORM, however I am not using the syntax CHANGING in my code, as it was also not used prior.
Please do tell me if you need additional information.
Thank you all in advance!
This problem can occur when FORM and PERFORM are in different includes and you only activate one but not the other.
When you activate an include, then it is checked against the active version of all other repository objects it depends on. Not the saved version. This can lead to an annoying catch-22 situation. You can not activate A because it does not match the previous version of B, and you can not activate B because it does not match the previous version of A.
The solution to this conundrum is to activate both objects together. When you activate something in SE80 and you have multiple inactive objects, you get a window where you can select multiple objects to activate together:
In Eclipse, you get a similar list by clicking on the "activate multiple" button:

Pentaho Report Design conditions

I want to put one condition for the columns in the report. I am passing a parameter called "TEMPLATE", I want to make some of the columns in report visible only if the values of passed parameter lies IN ["A","B",C","D"]. I am putting it like:
=IF([TEMPLATE]IN("A";"B";"C";"D";"E");TRUE();FALSE());
But it says syntax error every time and doesn't work. Can someone please help me in making it correct.
This is the correct syntax:
=IF(IN([TEMPLATE];"a";"b";"c");TRUE();FALSE())
where is
IN(<condition>;<sample1>;<sample2>;...)
returns true if <condition> equals to one of the <sampleX>. Otherwise return false.

SSRS Multiselect parameter error

I have a project that I need to add a param to that accepts multiple values. While this should sound pretty easy it is not working.
Here is the param: #queue_group varchar(100)
And here is how it is used: and g.extension in (#queue_group)
Now when I manually do it like so: and g.extension in ('700', '702') it works just fine. I have to make the numbers a string because of how the column was setup it has some string values in it such as *86 that breaks when I just do 700, 702.
Now I set up the param in SSRS giving it available values and allowing multiple select but every time it doesn't work because it can't find any results. The ultimate error is a divide by zero which is because it isn't finding any records.
How can I make SSRS mimic my manual behavior of '700', '702' which when I remove the param and enter that manually it runs just fine.
In SSRS I've tried Available Values CS = 700, CS = '700', CS = =Cstr(700) and CP = 702, CP = '702', CP = =CStr(702).
I've now tried setting up a table and using that as the defined values for the parameter. It now works when I select a single option and returns results. whenever I select 2 it returns me 0 results.
I'm at a loss.
SSRS can support multi-value parameters without much extra work so long as the dataset is in ssrs.
Here is a link to the tech net on it:
https://technet.microsoft.com/en-us/library/aa337396(v=sql.105).aspx
What happens is that SSRS passes the whole query to the sql compiler, this means that the replacement of the parameter with the multi-value string happens before compile. So I don't think that's the problem, because If it were an error in the way the multi-value param was presenting the data to the compiler it would not be a divide by zero.
Instead I'm thinking this has to do with how the parameter is populated. You have the param set to a text field, so people are expected to enter their own values. However SSRS handles the formating for a text field before it's sent to compile, and I'm guessing that's what tripping you up.
If you enter "402,407" without the quotes into the param at compile time it will be transformed into:
and g.extension in ('402,407')
That would not return any results. If this is just a report you use, you could enter: "402','407" without the double quotes and at compile time it would transform it too:
and g.extension in ('402','407')
The better solution would be to create a data set for the param, set the parameter to use that data set as it's list of available values, and check the multi-value property for the param. That way you would select multiple values from a drop down, and the user wouldn't have to mess with the string formatting.

BIRT report variable is always null when passed going to service

i wanted to pass a dataset row values to report variable just like in this example
Everything works great as expected. I can even print the text in a label using vars["Foo"] as stated in the example. But when I used that vars["Foo"] to datasource property binding like "http://localhost:8081/someService?fooIdList=" + vars["Foo"], fooIdList is always null.
why is that? Is there a way I can pass it going to a service? thanks
This is a tough answer because there are many issues involved.
Firstly, there is a kind of egg-and-chicken problem: datasources are built by the birt engine before datasets are processed. Therefore we can't make use of the result of a dataset in property bindings of a datasource.
Declaring a dataset in a report does not mean it will be triggered: in the example you provided, if we don't drag the column "Foo" into the report then "FooDataset" would never run and the report variable would not be initialized.
This is very important to understand the execution order: if we want to populate a report variable from a dataset D1, and make use of it in a Dataset D2, then D1 must be triggered by the report before D2: for example we drag a data element from D1 at the beginning of the report, and set the visibility to false.
You should probably declare your datasource as "Scripted" and make use of a scripted dataset to access the service. You can get a nice example of a scripted dataset here
I hope it helps.

Filling parameter with value from Zeconfig_var table

I have the following selection parameter:
PARAMETERS: p_ver(2) AS LISTBOX VISIBLE LENGTH 5.
I would like to populate it with the results from a ZECONFIG_VAR table.
At what point would I do this. Selection Screen Output, Start of Selection, or other. I am trying to allow users the ability to decide what version of the web service they would like to call. The config table will have different url's for the different versions.
I have looked at this Answer and the tutorial provided does not make sense to me.
I would do it at the event INITIALIZATION
However, it may be even easier to just create a search-help, and assign it to p_ver using the following:
parameters: p_ver(2) visible lenghth 5 MATCHCODE OBJECT zshelpname.
Esti is right that you probably want to fill an internal table from the DB table during INITIALIZATION.
But to the populate the listbox parameter, you need to put the call to VRM_SET_VALUES in AT SELECTION-SCREEN OUTPUT.