水晶报表子报表中的共享变量未显示在主报表的页眉中

发布于 2024-12-10 23:41:38 字数 690 浏览 0 评论 0原文

我有一个子报告部分,显示与订单相关的详细信息(行项目)。在此子报告中,我创建了一个共享变量,用于返回权重字段的总和:

WhilePrintingRecords;
Shared numbervar WeightTotal := Sum ({Report.TotalWeight})

在我的主报告中,我创建了另一个变量来显示子报告总重量:

WhilePrintingRecords;
shared numbervar WeightTotal;
WeightTotal;

这对于在报告页脚或页面中显示总计非常有效页脚。但是,我需要在页眉中显示此金额。

我尝试使用 EvaluateAfter() 函数创建另一个报告变量,以尝试将此数据引入标题部分。那行不通。

我还尝试按照以下线程在主报告中创建全局变量的建议: Crystal Reports:全局变量运行总计未显示在标题中

执行这样的任务是否可能?底层数据由 sp 生成(两者在几个不同的报告中共享)。我可以开发一个新的 sp 来简单地总结这个总数,但我更愿意将其委托给水晶。

I have a sub report section that displays details (line items) related to an order. Within this sub report I have created a shared variable for returning the sum of a weight field:

WhilePrintingRecords;
Shared numbervar WeightTotal := Sum ({Report.TotalWeight})

In my main report I have created another variable to display the sub reports total weight:

WhilePrintingRecords;
shared numbervar WeightTotal;
WeightTotal;

This works fine for displaying the total within the report footer or the page footer. However, I need to display this amount in the page header.

I have tried creating another report variable with the EvaluateAfter() function to attempt to bring this data into the header section. That didn't work.

I have also tried following the suggestions of creating a global variable in the main report as per this thread: Crystal Reports: global variable running total not displaying in header

Is performing a task like this even possible? The underlying data is generated by sp's (both shared across a few different reports). I could break out a new sp to simply sum this total but I would prefer to delegate this to crystal.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月光色 2024-12-17 23:41:38

问题是,虽然在第二个公式中使用 WhilePrintingRecords 会迫使 Crystal 在最终评估过程中比正常情况晚评估它,但这也是评估子报表的时间。这意味着主报表中的任何公式都会相对于子报表进行处理。在您的情况下,即使使用 WhilePrintingRecords 关键字,标题中的公式也会在详细信息部分中的子报表之前进行计算。该图对于理解不同的通道非常有用:多通道报告流程

您可以尝试使用 SQL 表达式对每个详细信息部分进行简单的聚合求和。由于不了解您的数据源或架构,因此很难给出示例,但这是总体思路。您可以对数据源使用任何有效的 SQL,只要它返回标量即可。

select sum(weight)
from table
where table.orderID="table"."orderID"

另一种方法是为每个订单使用额外的内部分组级别,完全摆脱子报告,并使用 Crystal 的 sum() 函数或全局变量来获取每个内部组的权重。

The problem is that while the use of WhilePrintingRecords in your second formula forces Crystal to evaluate it later than normal during the final evaluation pass, this is also when subreports are evaluated. This means that any formulas in the main report are processed relative to the subreport. In your case, the formula in the header is evaluated before the subreport in the details section, even with the WhilePrintingRecords keyword. This diagram is awesome for understanding the different passes: Multi-Pass Reporting Process.

You could try using a SQL Expression to do a simple aggregate summation for each details section. Not knowing anything about your data source or schema it's hard to give an example, but here's the general idea. You can use any valid SQL for your data source as long as it returns a scalar.

select sum(weight)
from table
where table.orderID="table"."orderID"

An alternative would be to use an additional inner grouping level per order, get rid of the subreports altogether, and use Crystal's sum() function or a global variable to get the weight per inner group.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文