2009-07-26 131 views
1

在我的水晶报表公式下面一行是给错误:水晶报表总和错误:“缺少)”

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中运行它时,报告运行正常。

但是,当我从利用Visual Studio .NET 2008的Crystal Reports Basic(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 := 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", "") + "%"*

事实证明,这是造成问题的最后一行。任何想法为什么?我通过从中删除Replace,Int和Roundup函数来修复它(删除了过程中的一些括号。)

注意:对于该代码格式不佳的抱歉,我无法让代码标记放置好与

回答

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参数。

2

从晶体中的多行复制粘贴我会:

  1. 定义在细节部分的基团为{sp_YES_AccountSnapshot;1.Cust}
  2. 更新的功能类似于:

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

  3. 在组

  4. 禁止该组头

您可能需要使用叠加部分下面的选项(参见节专家)的页脚中的函数来得到你想要的布局。

+0

自从我上一次在Crystal中进行速成课程已经过去了大约8个月。让我看看我是否正确理解你。步骤1的目的是为每个“客户”(客户)创建一些类别的部分。然后,我们不需要在公式中添加客户标识符,因为公式将在这些“客户部分”的页脚内使用。然后,我们要显示的是页脚..所以我们将隐藏标题并做其他必要的事情。我离现实有多近?谢谢对不起,无奈:) – 2009-07-26 08:38:00

+0

你是对的。 – 2009-07-26 16:52:42

+0

关于我上面编辑rexem的任何想法?谢谢。 – 2009-07-27 07:59:11

2

多return语句是不是一个好主意:

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知道要打印什么。这也确保了数据类型始终相同。