Crystal 2013 年报告:公式重复相同的错误

Crystal Reports 2013: Formula repeating same error

第一次尝试使用 Crystal 报告进行编程。我正在尝试写一个足够简单的。有不同的字段组合在一起,我打算 运行 每个组的公式。下图中是一组示例。

图像右上角突出显示的 20.00shipctns。我的公式是

Local NumberVar RTotal := 0;
Local NumberVar diff := 0;
While RTotal <  {@shipctns} DO
(
 If ({@pickctns} <  {@shipctns}) AND (RTotal + {@pickctns} < {@shipctns}) THEN
    "Pick";
    RTotal := RTotal + {@pickctns};
 Else If  {@pickctns} <  {@shipctns}  THEN
    "Pick " & ({@shipctns} - RTotal);

 Else
    "Don't Pick"
); 

该公式仍在进行中。就是把每个组里的Pick Ctns遍历一遍,说挑这个量补上shipctns个量。只有最后Pick Ctns的select部分如果太大就停止。

我的问题是我无法真正测试公式,因为我在 Else If 上遇到错误 "The ) is Missing"。我真的不知道 Crystal 报告,所以我在这里做错了什么?

您需要用括号将 thenelse 块中的多个语句括起来。

来自 Crystal 报告文档:

The correct Crystal syntax for If statements is if <condition> then <then> else <else>, where <condition>, <then>, and <else> are all single expressions. If you have multiple expressions after the <then> or <else>, convert them into single expressions by surrounding them in parentheses.

您的公式应如下所示

...
If ({@pickctns} <  {@shipctns}) AND (RTotal + {@pickctns} < {@shipctns}) THEN
(
    "Pick";
    RTotal := RTotal + {@pickctns};
)
Else If  {@pickctns} <  {@shipctns}  THEN
    "Pick " & ({@shipctns} - RTotal);
Else
...