Author |
Message |
Emir_W
Senior Member
Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
|
Topic: Passing a value from SubReport to MainReport Posted: 15 Nov 2020 at 2:02am |
I have created a report for stock transaction within a date range. And it's working fine.
And requested to add 1 column after item description with Last Qty from previous day/month.
There is a table in the system itself which contains that information (table name ItmLcDailyTotal). They are: Date, QtyBeg, PriceBeg, QtyEnd, PriceEnd.
Whenever there is a transaction for an item, it will update this table.
So, my plan is to take the QtyValue from previous date from the "Date From" and read the transactions in date range, and calculate for last final value.
I've tried with Sub-Report to take only the value from date before DateFrom and pass it to Main Report. It worked. But I cannot calculate it for final value.
e.g.:
Item R004-PH02-01, value from last month is 9.
Transactions in current month:
5 Received and 2 Sold.
In this case, Final value will be 9 + 5 - 2 = 12.
My report give me 0.
Can someone help me?
|
Emir W
|
IP Logged |
|
Emir_W
Senior Member
Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
|
Posted: 15 Nov 2020 at 2:32am |
I can email you a screenshot or the CR file if needed.
|
Emir W
|
IP Logged |
|
Emir_W
Senior Member
Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
|
Posted: 15 Nov 2020 at 9:00pm |
I have created some variables.
Report Header
Global Numbervar TotGrpQty; //GroupTotal;
global numbervar TotQty;
shared numbervar TotGrpQty:=0;
shared numbervar TotQty:=0;
Group Header1 (Location)
Group Header2 (ItmCode)
Global Numbervar TotGrpQty; //GroupTotal;
global numbervar TotQty;
shared numbervar TotGrpQty:=0;
shared numbervar TotQty:=0;
Group Footer2
--> SubReport[StockQtyDaily]
--> Group Header (Date)
--> Group Footer
whileprintingrecords;
shared numbervar Totvalue:=
{INC_ItmLcDailyTotal.DAY_QtyEnd};
Totvalue
--> Report Footer
Global Numbervar TotGrpQty; //GroupTotal;
shared numbervar TotGrpQty;
Whileprintingrecords;
TotGrpQty := {INC_ItmLcDailyTotal.DAY_QtyEnd};
TotGrpQty //GrandTotal
Summary for TotalTransfer; (in MainReport)
Summary for TotalDispose; (in MainReport)
Summary for TotalConsume; (in MainReport)
But it didnot work.
Did I missed something?
|
Emir W
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 16 Nov 2020 at 4:25am |
Where is your sub-report located? Remember it has to be in a section prior to doing the calculation and it cannot be suppressed.
|
IP Logged |
|
Emir_W
Senior Member
Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
|
Posted: 16 Nov 2020 at 9:22pm |
my SubReport located in Group Footer 2 (ItmCode) and it's not suppressed.
I suppressed for GH1, GH2, Detail, and GF1.
|
Emir W
|
IP Logged |
|
Emir_W
Senior Member
Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
|
Posted: 17 Nov 2020 at 2:33am |
I've put my SubReport in GF2, but it didnot work. I cannot get the value from SubReport, always shows as 0 while there is a value.
Than I move my SubReport in detail section (suppress). Still no luck.
|
Emir W
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 17 Nov 2020 at 4:28am |
Double check the name of the shared variable(s) in the main report and the sub-reports. Easy thing to overlook.
|
IP Logged |
|
Emir_W
Senior Member
Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
|
Posted: 18 Nov 2020 at 8:09pm |
I've checked all the variables in MR and SR, all same.
Here are the variables and where I put it.
Main Report - Report Header
Global Numbervar TotGrpQty;
global numbervar TotQty;
shared numbervar TotGrpQty;
shared numbervar TotQty;
Group Header2 (Suppress)
Detail (Suppress)
Group Footer2
SubReport
Group Header (Suppress)
Details (Suppress)
Group Footer (Suppress)
global numbervar TotGrpQty;
whileprintingrecords;
shared numbervar TotGrpQty;{INC_ItmLcDailyTotal.DAY_QtyEnd};
TotGrpQty
Report Footer
Global Numbervar TotGrpQty;
shared numbervar TotGrpQty;
Whileprintingrecords;
TotGrpQty:= {INC_ItmLcDailyTotal.DAY_QtyEnd};
TotGrpQty
|
Emir W
|
IP Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|
Posted: 19 Nov 2020 at 4:33am |
You said that you put the sub-report in GF2? It appears that you have GF2 suppressed, that will not work. Sub-reports in suppressed sections do not run.
|
IP Logged |
|
Emir_W
Senior Member
Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
|
Posted: 21 Nov 2020 at 6:51pm |
In MainReport, I've put SubReport in GF2 and not suppressed. I can see the result from SubReport in Main Report, but I cannot calculate it.
So, the issue is passing the value from SubReport to MainReport in order for me to get it for calculation.
|
Emir W
|
IP Logged |
|
|