cancel
Showing results for 
Search instead for 
Did you mean: 

Passing array values to a sub report

Former Member
0 Kudos

Hi everyone,

I had a little problem with passing values to a sub report through array.

I have two groups in my main report. And in the second group I want to store the values being printed out in the array and pass them to the sub report.

I created a formula in the main report and placed it in the second group footer.

Then I placed the sub report in the first group footer and created a formula to retrieve the values of the array. But the same value printed on every page.

What am I missing?

Thank you.

Here's the formula I created in the main report:                                             This is the formula in the sub report:

WhilePrintingRecords;                                                                               WhilePrintingRecords;

shared numberVar array values;                                                                shared numberVar i;

shared numberVar i;                                                                                   local numberVar j;

i:=i+1;                                                                                                         numbervar v;

redim preserve values[i];                                                                           shared numberVar array values;

if i=1 then                                                                                                  for j:=1  to i step 1 do 

values[i]:={@total}                                                                                     v:=values[j];

else if not({@total} in values[1 to i]) then                                                   v;

values[i]:={@total}

else

(

i:=i-1;

)

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Nebil,

What exactly are you trying to do with the array formula on the Main Report - only store 'unique' values that appear on the Group #2?

And, what exactly do you do with the array formula inside the Subreport? Display it somewhere?

-Abhilash

Former Member
0 Kudos

Yes I wanted to store values that appear on Group #2. Then use them for a calculation in the sub report based on their appearance on Group #2 in the main report.

abhilash_kumar
Active Contributor
0 Kudos

Could you provide an example of what you're trying to do inside the Subreport?

Also, you didn't answer whether you're storing just the 'unique' values from Group #2 in the array.

-Abhilash

Former Member
0 Kudos

Sorry, basically it will store values that are results of a calculation so they are surely unique.

To give you an example, if I have an item A in group #2, there will be a calculation performed for that item and finally stored in some variable, in this case the array. So the array will store the values for each  available item in group #2.

Inside the sub report there will be items that correspond to items in the main report. So for item A in sub report the array will assign a value that was stored in it. Then perform another calculation in the sub report with the passed value.

I hope it makes sense. Otherwise i will upload a picture of the work I'm doing.

abhilash_kumar
Active Contributor
0 Kudos

Assuming position 1 of the array corresponds to value 1 of the Group in the Subreport, 2 corresponds to value 2 in the Subreport, try this:

whileprintingrecords;

shared numbervar array values;

numbervar x := x + 1;

values[x];

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

That's so helpful of you. It works like magic.

But is it possible to display the values only with the matching items in the main report.

For example let items A,B and C are in the main report and have values.If item B doesn't exist in the sub report,ignore the value at index 2 of the array and assign the value at index 3 to item C.

If it's not possible I'll manage that mark it as an answer

But again thank you

abhilash_kumar
Active Contributor
0 Kudos

Hi Nebil,

That is certainly do-able! Please post that as a separate question as the solution to it and approach is completely different.

-Abhilash

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try Using Join And Pass it as Text .

ToText(Join( ({YourArray}) , ","))

I use Below Code for Passing in Open Doc .

Replace(Replace( ToText(Join( ({YourArray}) , "],[")),"&","%26"),"+","%2B")+"]"