Crystal Reports Summation Error:“The)缺失”

时间:2009-07-26 07:15:12

标签: asp.net crystal-reports runtime

我的水晶报告公式中的以下行给出错误:

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报告11创建的。

当我从Crystal Reports中运行报告时,报告运行正常。

但是,当我使用Crystal Reports Basic for Visual Studio .NET 2008(2008年5月更新)(在http://resources.businessobjects.com/support/additional_downloads/runtime.asp#09提供)从ASP.NET Web应用程序运行报表时,这是我收到错误的时候

我猜测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})+ Sum   ({sp_YES_AccountSnapshot; 1.DR0304_Ext},   {sp_YES_AccountSnapshot; 1.Cust});如果sales0304 = 0那么       ToText(“增加销售额:不适用”)否则如果(sales0405< sales0304)那么       ToText(“”)其他       “销售增加:”+替换(ToText(Int(RoundUp((((sales0405 - sales0304)/ sales0304)* 100)))),“。00”,“”)+“%”*

事实证明,这是导致问题的最后一行。任何想法为什么?我通过删除它的Replace,Int和Roundup函数来修复它(在这个过程中省略了几个括号。

注意:抱歉使用该代码的格式不佳,我无法使代码标签与水晶的多行复制粘贴放在一起。

3 个答案:

答案 0 :(得分:2)

我会:

  1. {sp_YES_AccountSnapshot;1.Cust}
  2. 的详细信息部分中定义一个组
  3. 将功能更新为类似:

    NumberVar sales0405 := SUM({sp_YES_AccountSnapshot;1.ST0405_Ext}) + SUM({sp_YES_AccountSnapshot;1.DR0405_Ext});

  4. 将该功能放在组的页脚

  5. 取消群组标题
  6. 您可能必须使用Overlay Section Beneath选项(请参阅Section Expert)来获得所需的布局。

答案 1 :(得分:2)

多个返回语句绝不是一个好主意:

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}); 

Stringvar output;

IF sales0304 = 0 THEN 
  output := ToText ("Increase in Sales: N/A") 
ELSE IF(sales0405 < sales0304) THEN 
  output := ToText ("") 
ELSE 
  output := "Increase in Sales: " + Replace (ToText (Int(RoundUp ((((sales0405 - sales0304) / sales0304) * 100)))), ".00", "") + "%";

输出;

最后一行,声明“输出”变量是必需的,以便Crystal知道要打印的内容。这也可以确保数据类型始终相同。

答案 2 :(得分:1)

刚出现这个问题,这篇文章引发了我的问题,即函数RoundUp()

该函数是在Crystal Reports XI中引入的,您说您在其中创建了报表。如果您使用较旧的客户端库(我正在编写的一个软件使用的是版本9),则该函数不存在,您报告的错误发生。

"The ) is missing"

我认为如果您创建一个自定义函数来替换RoundUp(),调用任何您喜欢的内容,例如_RoundUp()

Function (NumberVar num, Optional NumberVar places := 0) (
    -int(-num * (10 ^ places)) / (10 ^ places)
)

这是有效的,因为int()函数实际上是floor(),并向下舍入到最接近的整数。因此,取整数的负数,将其铺设,并删除负数将导致舍入功能(通过地板上限)。

通过比例因子预分频和后分频来反转比例,places参数可以满足。