【问题标题】:Crystal Reports Summation Error: "The ) is missing"Crystal Reports 总和错误:“缺少 )”
【发布时间】:2012-09-29 20:56:48
【问题描述】:

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

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}) + 总和 ({sp_YES_AccountSnapshot;1.DR0304_Ext}, {sp_YES_AccountSnapshot;1.Cust});如果 sales0304 = 0 那么 ToText ("Increas in Sales: N/A") else if(sales0405

事实证明,是最后一行导致了问题。知道为什么吗?我通过从中删除 Replace、Int 和 Roundup 函数来修复它(在此过程中删除了一些括号。

注意:抱歉,该代码格式不佳,我无法使用水晶的多行复制粘贴将代码标签放置得很好。

【问题讨论】:

    标签: asp.net crystal-reports runtime


    【解决方案1】:

    我愿意:

    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. 抑制组标题

    您可能必须使用 Overlay Section Beneath 选项(请参阅 Section Expert)来获得您想要的布局。

    【讨论】:

    • 距离我上次在 Crystal 上的速成课程已经过去了大约 8 个月。让我看看我是否理解正确。第 1 步的目的是为每个“客户”(客户)创建某种类型的部分。然后,我们不需要将客户标识符放入公式中,因为公式将在这些“客户部分”的页脚中使用。然后,我们想要显示的只是页脚.. 所以我们将隐藏页眉并做任何其他必要的事情。我离现实有多近?感谢和抱歉的无知:)
    【解决方案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 知道要打印什么。这也确保数据类型始终相同。

    【讨论】:

      【解决方案3】:

      刚遇到这个问题,这篇帖子让我想到了函数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 参数可以满足。

      【讨论】:

        猜你喜欢
        • 2016-02-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-09-26
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多