Crystal Reports 求和错误:“缺少 )”
我的 Crystal Reports 公式中的以下行给出了错误:
NumberVar sales0405 := Sum ({sp_YES_AccountSnapshot;1.ST0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + Sum ({sp_YES_AccountSnapshot;1.DR0405_Ext}, {sp_YES_AccountSnapshot;1.Cust});
错误:
"The ) is missing"
该报告是使用 Crystal reports 11 创建的。
当我从 Crystal Reports 中运行该报告时,该报告运行良好。
但是,当我使用 Crystal Reports Basic for Visual Studio .NET 2008(2008 年 5 月更新)(在 http://resources.businessobjects.com/support/additional_downloads/runtime.asp#09),这是我收到错误的时候。
我猜想新版本的 Crystal Reports 的汇总有一些变化,但我无法找到有关此特定问题的任何文档。
我已经验证我的测试用例中没有出现产生错误的空值。
产生错误的行是公式的第一行。
提前感谢您抽出时间
编辑:这是整个公式
*NumberVar sales0405 := Sum ({sp_YES_AccountSnapshot;1.ST0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + Sum ({sp_YES_AccountSnapshot;1.DR0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}); NumberVar sales0304 := 总和 ({sp_YES_AccountSnapshot;1.ST0304_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + 总和 ({sp_YES_AccountSnapshot;1.DR0304_Ext}, {sp_YES_AccountSnapshot;1.Cust}); 如果 sales0304 = 0 那么 ToText ("销售额增加:N/A") else if(sales0405 < sales0304) then ToText ("") 其他 “销售额增加:” + Replace (ToText (Int(RoundUp ((((sales0405 - sales0304) / sales0304) * 100)))), ".00", "") + "%"*
因为它事实证明,正是最后一行导致了问题。知道为什么吗? 我通过删除其中的 Replace、Int 和 Roundup 函数来修复它(删除过程中的一些括号。
注意:很抱歉该代码的格式设置很差,我无法将代码标记与 multi- 很好地放置在一起)从水晶线复制粘贴。
The following line in my crystal reports formula is giving the error:
NumberVar sales0405 := Sum ({sp_YES_AccountSnapshot;1.ST0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + Sum ({sp_YES_AccountSnapshot;1.DR0405_Ext}, {sp_YES_AccountSnapshot;1.Cust});
The error:
"The ) is missing"
The report was created using Crystal reports 11.
The report runs fine when I run it from within Crystal Reports.
However, when I run the report from an ASP.NET web app utilizing the Crystal Reports Basic for Visual Studio .NET 2008 (Updated May 2008) (provided at http://resources.businessobjects.com/support/additional_downloads/runtime.asp#09), this is when I get the error.
I'm guessing there is some change in summations with the newer versions of Crystal Reports, but I've been unable to find any documentation on this specific issue.
I have verified that there are no null values coming in on my test case that produces an error.
The line that is producing the error is the first line of the formula.
Thanks in advance for your time
Edit: Here's the entire formula
*NumberVar sales0405 := Sum ({sp_YES_AccountSnapshot;1.ST0405_Ext}, {sp_YES_AccountSnapshot;1.Cust}) + Sum
({sp_YES_AccountSnapshot;1.DR0405_Ext},
{sp_YES_AccountSnapshot;1.Cust}); NumberVar sales0304 := Sum
({sp_YES_AccountSnapshot;1.ST0304_Ext},
{sp_YES_AccountSnapshot;1.Cust}) + Sum
({sp_YES_AccountSnapshot;1.DR0304_Ext},
{sp_YES_AccountSnapshot;1.Cust}); if sales0304 = 0 then
ToText ("Increase in Sales: N/A") else if(sales0405 < sales0304) then
ToText ("") else
"Increase in Sales: " + Replace (ToText (Int(RoundUp ((((sales0405 - sales0304) / sales0304) * 100)))), ".00", "") + "%"*
As it turns out, it's that last line that's causing the problem. Any Idea why? I fixed it by removing the Replace, Int, and Roundup functions from it (eliminating a few parentheses in the process.
Note: sorry about the poor formatting with that code, I couldn't get the code tag to place nice with the multi-line copy paste from crystal.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会:
{sp_YES_AccountSnapshot;1.Cust}
的详细信息部分定义一个组更新函数以类似于:
NumberVar sales0405 := SUM({sp_YES_AccountSnapshot;1.ST0405_Ext}) + SUM({sp_YES_AccountSnapshot;1.DR0405_Ext});
将函数放置在组的页脚
您可能必须使用“覆盖部分下方”选项(请参阅“部分专家”)才能获得所需的布局。
I would:
{sp_YES_AccountSnapshot;1.Cust}
Update the function to resemble:
NumberVar sales0405 := SUM({sp_YES_AccountSnapshot;1.ST0405_Ext}) + SUM({sp_YES_AccountSnapshot;1.DR0405_Ext});
Place the function in the footer of the group
You might have to use the Overlay Section Beneath option (see the Section Expert) to get the layout you desire.
多个 return 语句从来都不是一个好主意:
输出;
最后一行需要声明“输出”变量,以便 Crystal 知道要打印什么。 这也确保了数据类型始终相同。
Multiple return statements are never a good idea:
output;
The last line, declaring the "output" variable is required so that Crystal knows what to print. This also ensures the data type is always the same.
刚刚遇到这个问题,这篇文章让我发现了函数
RoundUp()
的问题。该函数是在 Crystal Reports XI 中引入的,您说您在其中创建了报表。如果您使用较旧的客户端库(我正在编写的一个软件使用版本 9),则该函数不存在,并且您会出现错误发生报告。
我认为如果您创建一个自定义函数来替换
RoundUp()
,无论您喜欢什么,都可以调用_RoundUp()
:这有效,因为
int()< /code> 函数实际上是一个
floor()
,并向下舍入到最接近的整数。 因此,取整数的负数,将其取整,然后删除负数将导致向上舍入功能(从下限到上限)。通过预先乘以比例因子并进行后除以反转比例,可以满足
places
参数。Just had this problem, this post led me to the issue which is the function
RoundUp()
.The function was introduced in Crystal Reports XI, which you say you created your report in. If you use an older client library (a piece of software I was writing for is using version 9), then the function does not exist and the error you reported occurs.
I think if you create a custom function to replace
RoundUp()
, called whatever you like,_RoundUp()
for instance:This works because the
int()
function is effectively afloor()
, and rounds down to the nearest integer. So taking the negative of the integer, flooring it, and removing the negative will result in round-up functionality (ceiling via floor).By pre-multiplication by a scale factor and post-division to reverse the scaling, the
places
argument can be catered for.