cancel
Showing results for 
Search instead for 
Did you mean: 

Shared Variable

Former Member
0 Kudos

Hi All,

I have a sub report in that i created  a formula like this.

local numberVar vararesult;

local numbervar ads ;

local numbervar atrans;

if ({Command.tarAds})>=({Command.actAds}) and ({Command.tarTrans})>=({Command.actTrans})

then  vararesult := {Command.tarSale}-{Command.actSale}

else (

    if {Command.tarAds}>{Command.actAds} then

   ads  := {Command.tarAds}

    else

ads :=  {Command.actAds};

    if {Command.tarTrans}>{Command.actTrans} then

        atrans :={Command.tarTrans}

    else

atrans :={Command.actTrans};

vararesult := (ads *atrans)-{Command.actSale} )


Now in the main report i need to show sum of this formula.I tried using shared variable but getting errors,as my formula already contains some local variables.

Ex:

                      12

                       3

                       4

                       5

sum:               24

Please suggest

Accepted Solutions (1)

Accepted Solutions (1)

abhilash_kumar
Active Contributor
0 Kudos

Hi Francis,

Open the formula in the Subreport and modify the code to this:

local numberVar vararesult;

local numbervar ads ;

local numbervar atrans;

shared numbervar tot;

if ({Command.tarAds})>=({Command.actAds}) and ({Command.tarTrans})>=({Command.actTrans})

then  vararesult := {Command.tarSale}-{Command.actSale}

else (

    if {Command.tarAds}>{Command.actAds} then

   ads  := {Command.tarAds}

    else

ads :=  {Command.actAds};

    if {Command.tarTrans}>{Command.actTrans} then

        atrans :={Command.tarTrans}

    else

atrans :={Command.actTrans};

vararesult := (ads *atrans)-{Command.actSale} );

tot := tot + vararesult;

vararesult;

Go back to the Main report and create a formula to display the result.

shared numbervar tot;

NOTE: The display formula needs to be placed on the Main Report in a section below the subreport, otherwise you won't see the results. For e.g. if the Subreport is in Report Header a, then the display formula needs to go in Report Header b or any other section below Report Header a.

-Abhilash

Former Member
0 Kudos

Hi Abhilash,

I did what you said but i am getting result like this.

I am getting result like running total.

PFA in attachment 1512,3024 are shared vars totals.

Ex:

Brand Category:A-a1 (Group)

1

2

3

Sum:6

Brand Category:A-a2  (Group)

1

2

3

sum:12        Here it should display 6

Brand Category:B-b1  (Group)

4

5

6

sum:27              Here it should display 15

Brand Category:C-c1  (Group)

2

1

8

sum:38          Here it should display  11




Former Member
0 Kudos

Just reset the variable in GH#2.  Place this formula and suppress it.

shared numbervar tot:=0;

Thanks,

Prathamesh

abhilash_kumar
Active Contributor
0 Kudos

Yep, just reset the variable like Prathamesh says and it should work.

-Abhilash

Answers (0)