0

我目前正在使用 Crystal Reports 2013 来运行报表。我遇到了一个需要查看 SAP 订单状态并且只打印出特定几个的公式的问题。SAP 订单状态字段由 2 个部分组成。

  • 第 1 部分:“A”“B”“C”“D”(仅从该列表中提取一个选项)
  • 第 2 部分:“E”“F”“G”“H”(在状态中可以有多个选择)
  • 示例订单 #1111 状态:“A:F:G”

我目前有一个公式可以从第一部分提取订单状态。

if (isnull({user_status}) or 
    {user_status}=" " or
        not ({user_status} like ["*A*", "*B*", "*C*", "*D*"])) then "N/A" else
if {user_status} like "*A*" then "A" else
if {user_status} like "*B*" then "B" else
if {user_status} like "*C*" then "C" else
if {user_status} like "*D*" then "D"

上面的代码片段只会为订单#1111 引入“A”并省略“F”和“G”。

我需要一个省略“A”并列出“F”和“G”的公式的帮助。

我尝试了以下方法:

if (isnull({user_status}) or 
    {user_status}=" " or
        not ({user_status} like ["*E*", "*F*", "*G*", "*H*"])) then "N/A" else
if {user_status} like "*E*" then "E" else
if {user_status} like "*F*" then "F" else
if {user_status} like "*G*" then "G" else
if {user_status} like "*H*" then "H"

但该公式只返回完整的“A;F;G”状态。


想出了答案。(2020 年 6 月 9 日)我使用以下代码创建了一个数组并循环遍历它,只提取我需要的内容。

NumberVar Counter;
StringVar finalStatus:= "";
StringVar array statusList;
statusList:= split({user_status},";");
//Loop through array and only print out Status w/o No values
FOR Counter := 1 to UBound(statusList) DO
(if statusList[Counter] like ["E", "F", "G", "H"] then
finalStatus:= finalStatus+statusList[Counter]+";" else "");
finalStatus

感谢您的输入。

4

0 回答 0