显示参数的描述值
在 Crystal Reports v 11 中,是否可以在报表上显示“参数描述”值,而不是仅显示参数值?每当我将参数拖到报表上显示它时,只显示值,并且我想打印说明。
注意:我使用的是 Crystal 11 (XI),而不是 .NET Crystal Report 插件。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我不相信有一种方法可以直接获取描述(散布在互联网上的其他几个帖子似乎也同意)。如果您的参数选项数量较少,您只需创建一个包含 case 语句的公式或函数,该语句会将值转换为其描述。
I don't believe there is a way to directly get at the description (several other posts scattered around the interwebs seem to agree). If you have a small(-ish) number of parameter options, you can just create a formula or function that contains a case-statement that will translate the value to its description.
我感到震惊的是,Crystal Reports 能够以某种方式检索参数的描述,但它不会将其公开以供公式中使用。在我看来,被迫重复参数和描述的定义似乎是一种不好的形式,因为在编程时不应该重复事物。另一种方法(除了列出的所有方法之外)是将您的值和描述设置为 SQL 数据源的值(在 SQL 中对它们进行硬编码)。然后,您可以从所述数据源填充参数,并且您将获得可用字段形式的描述。这样你就只有“一个版本的事实”,将你的价值观映射到你的描述,尽管更感人。
I got over the shock that Crystal Reports somehow is able to retrieve the description of a parameter but it doesn't expose it to be used in formulas. Being forced to duplicate the definition of parameters and description seems to me bad form, simply because one is not supposed to duplicate things when programming. An alternative hack (besides all the ones listed) would be to make your Values and Descriptions as values of a SQL data source (hardcode them in SQL). Then you can populate your parameter from said data source and you will have the Descriptions available as a field. That way you only have "one version of the truth" that maps your values to your descriptions, although more moving pieces.
请参阅:1678487 - 如何在 Crystal Reports 中显示参数描述而不是参数值:https://apps.support.sap.com/sap/support/knowledge/public/en/1678487
See: 1678487 - How to display parameter descriptions instead of parameter values in the Crystal Reports at: https://apps.support.sap.com/sap/support/knowledge/public/en/1678487
有一个新函数实际上可以用于在报告上显示参数的描述。
来源:https://launchpad.support.sap.com/#/notes/2037542< /a>
我将为那些无需访问此页面的用户粘贴整个文档。
Crystal Reports 2016 中添加了一个新函数 GetValueDescriptions(),允许用户创建可以操作/显示参数所选值的描述的公式。
GetValueDescriptions() 支持各种参数(单个和多个、离散和范围)。下面是一个公式示例,其中 {?customerMultiDiscreteAndRange} 是多个范围参数:
local stringVar range array im := GetValueDescriptions ({?customerMultiDiscreteAndRange});
本地编号Var i := 1;
本地 stringVar 输出 := "";
当 i <= count(im) 时
(
if (InincludesLowerBound ({?customerMultiDiscreteAndRange}[i])) then
( 输出 := 输出 + "["; )
别的
( out := out + "("; );
if (HasLowerBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + GetLowerBound(im[i]) );
输出:=输出+“..”;
if (HasUpperBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + GetUpperBound(im[i]) );
if (InincludesUpperBound ({?customerMultiDiscreteAndRange}[i])) then
(输出:=输出+“]”;)
别的
( 输出 := 输出 + ")"; );
如果 (i < count(im)) 那么
输出:=输出+“,”;
我:=我+1;
);
out;
还要注意两个新函数 - GetLowerBound() 和 GetUpperBound(),它们可用于获取正确的下限/上限描述。如果Maximum()和Minimum()返回交换的描述,这两个特别有用。
上述公式示例可以轻松调整,例如同时显示值和描述,或满足更多报告需求。
要使用这些功能,请将 Crystal Reports 升级到已进行增强的版本。
有关详细信息和可用补丁,请参阅 SP 补丁级别部分。
对于 SAP Crystal Reports(Eclipse 运行时版本):
仅自 SP22 起运行时才支持这些函数,但有以下限制:
SAP Crystal Reports(Eclipse 运行时版本)不支持静态多范围参数,这与以前相同。支持动态多范围参数。
SAP Crystal Reports(Eclipse 版本)的嵌入式设计器不支持显示描述的“值选项”。如果您在 SAP Crystal Reports 2016 中设计了一个现有报表,其中使用参数的“值选项”来显示说明,则在嵌入式设计器中重新保存的任何修改都将覆盖“值选项”以显示值。相反,SAP Crystal Reports(Eclipse 运行时版本)支持在 SAP Crystal Reports 2016 中使用“值选项”显示说明创建的报表。
要下载 SAP Crystal Reports Eclipse 版本的最新支持包:
https://wiki.scn.sap.com/wiki/display/BOBJ/SAP+Crystal+Reports+version+for+Eclipse+-+下载
There is a new function that can actually be used for displaying the descriptions of a parameter on a report.
Source : https://launchpad.support.sap.com/#/notes/2037542
I will paste the entire document for those users who don't have to access to this page.
A new function GetValueDescriptions() is added in Crystal Reports 2016, to allow user create formula that could operate / display descriptions of selected value for a parameter.
GetValueDescriptions() supports all kinds of parameters (single and multiple, discrete and range). Below is an formula example where {?customerMultiDiscreteAndRange} is a multiple range parameter:
local stringVar range array im := GetValueDescriptions ({?customerMultiDiscreteAndRange});
local numberVar i := 1;
local stringVar out := "";
while i <= count(im) do
(
if (IncludesLowerBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + "["; )
else
( out := out + "("; );
if (HasLowerBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + GetLowerBound(im[i]) );
out := out + "..";
if (HasUpperBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + GetUpperBound(im[i]) );
if (IncludesUpperBound ({?customerMultiDiscreteAndRange}[i])) then
( out := out + "]"; )
else
( out := out + ")"; );
if (i < count(im)) then
out := out + ", ";
i:= i + 1;
);
out;
Also note two new functions - GetLowerBound() and GetUpperBound(), they can be used to get correct lower / upper bound descriptions. These two are especially useful if Maximum() and Minimum() returns swapped descriptions.
Above formula example can be adjusted easily, e.g. to show both the value and descrition, or to satisfy more reporting needs.
To use these functions, upgrade your Crystal Reports to a release where the enhancement has been made.
See the SP Patch Level section for details and available patches.
For SAP Crystal Reports, version for Eclipse:
These functions are supported for runtime only since SP22, with following limitations:
Static multi-range parameters are not supported in SAP Crystal Reports, version for Eclipse runtime, which is the same as before. Dynamic multi-range parameters are supported.
"Value Options" to show description is not supported in the embedded designer in SAP Crystal Reports, version for Eclipse. If you have an existing report designed in SAP Crystal Reports 2016 with parameters' "Value Options" to show description, any modification resaved in the embedded designer will overwrite the "Value Options" to show value. Instead, reports created in SAP Crystal Reports 2016 with the "Value Options" to show description is supported in SAP Crystal Reports, version for Eclipse runtime.
To download the latest Support Packages of SAP Crystal Reports, version for Eclipse:
https://wiki.scn.sap.com/wiki/display/BOBJ/SAP+Crystal+Reports+version+for+Eclipse+-+Downloads
我同意 Ryan 的观点——没有一种本地机制可以获取这些值。用户函数库(UFL)可能是一种值得研究的方法。
相反,我通过多种方式处理这个问题:
I agree with Ryan--there isn't a native mechanism to grab these values. A user-function library (UFL) might be an approach worth investigating.
In lieu of that, I handle this a number of ways:
首先将参数值和描述连接在一起,并使用竖线“|”分隔两个值或其他较少使用的字符
示例:
客户 ID、客户名称 -> 12345|ABC Company
第二 使用带有数组的水晶函数来显示报告上的说明部分,即分隔字符
第三之后的所有内容。 创建第二个函数(如上面的函数)将参数值返回到分隔符左侧,以用作报表选择公式的一部分**
First, Concatenate the parameter value and the description together and delimit the two values using a pipe '|' or other lesser used character
Example:
CustomerID, CustomerName -> 12345|ABC Company
Second Use a Crystal function with an array to display the description side on your report i.e everything after your delimiting character
Third. Create a second function like the one above to return the Parameter value to the left of the delimiter to use as part of the report's Selection Formula**