Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Assign array values to items in a sub report

Hi everyone,

I have a certain group in the main report. For each item in that group i want to store a corresponding value in the array.

In the sub report which is placed in the main report there may or may not be items in a group that match with 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.

Is it possible to do that?

Thank you

Former Member

Hi Nebil,

Here's what you need to do :

1) In the existing formula on the Main Report, introduce another string array (alongside the number array that you already have) to store the group name at the same position. E.g:


shared stringvar array items;

shared numbervar array values;

numbervar x := x + 1;

redim preserve items[x] //this stores the group's name;

redim preserve values[x] //this stores the value for that particular group;

items[x] := {Group_Name};

values[x] := {@total} //your total formula;


2) Inside the Subreport, create a formula with this code:


shared stringVar array items;

shared numbervar array values;

numbervar i;

If {Group_Name} IN items then


    for i := 1 to ubound(items) do


        if items[i] = {Group_Name} then


            numbervar v := values[i];

            exit for;





Hope this helps.


0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question