Example of a custom report functions implementation
This topic illustrates the implementation of
a set of custom report functions.
The Sample files are located in the installation_location/webcontent/samples/sdk/crx/crxSDKsample directory. They are described in the following table.
File Name | Purpose | Description |
---|---|---|
crxSDKSample.cpp | sample C++ code | Is required to add the custom report functions. It will be compiled into a dynamic load library and referenced in the function definition file |
crxSDK.h | header file | Contains the report function prototype, and the type definitions used by CRX report functions. It must be referenced by an include statement in each dynamic load library you create for custom report functions. |
FileList_custom.xml | custom file list file | Identifies the custom function definition and description files. |
crxSDKSampleTree.xml | function definition file | Represents a custom group of functions. The file identifies the functions and their location to FDS. |
crxSDKSampleStrings_en.xml | function description file | Provides the strings that will appear to the report author in the expression editor. In this example, only an English description file is included. |
The functions are:
- A random integer generator
- A surface area calculator
- A date to a string converter
The following table shows the report function declaration and the function name and syntax that the report author sees in the expression editor.
Function Declaration in C++ | Function Name and Syntax |
---|---|
CCLDBColumnState SDKRandomInt ( void* result,
const crxDataI* context); |
SDKRANDOMINT() |
CCLDBColumnState SDKArea ( void* result,
const crxDataI* context, const CCL_float64 arg1 const CCL_float64
arg2 const CCL_char arg3 ); |
SDKAREA ([base],[height],[shape]) |
CCLDBColumnState SDKDateToString ( void*
result, const crxDataI* context const QSDate* date |
SDKDATETOSTRING(date) |
Example of a custom file list file
The following is a segment of the custom file list.
<filelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="FileList.xsd">
<definition>crxSDKSampleTree.xml</definition>
<description>
<language>en-us</language>
<file>crxSDKSampleStrings_en.xml</file>
</description>
</filelist>
Example: crxSDKSampleTree.xml
The following is a segment of the
function definition file showing the definition of the Area
function.
...
<functionsRoot xsi:schemaLocation=
"http://www.developer.cognos.com/schemas/commonfunctionservice/1/0 FuncTree.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<id>SDKTEST</id>
<!--CRX SDK Test Functions-->
...
<function>
<id>crx_sdk_area</id>
<canonical>SDKArea</canonical>
<name>SDKArea</name>
<dll>CRXSampleSDKFunctions</dll>
<context>CRX</context>
<returnType>crxDTypeDouble</returnType>
<parameter>
<type>crxDTypeDouble</type>
</parameter>
<parameter>
<type>crxDTypeDouble</type>
</parameter>
<parameter>
<type>crxDTypeString</type>
</function>
...
</group>
</functionsRoot>
Example: crxSDKSampleStrings_en.xml
The following is a segment of the English function description file showing the Area function.
...
<stringTable xsi:noNamespaceSchemaLocation="CCLMessageFile.xsd"
usage="String"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<component name="CRN">
<section name="TST">
...
<string id="crx_sdk_area">SDKAREA</string>
<string id="crx_sdk_area.syntax">SDKAREA(numeric_exp, numeric_exp, shape)</string>
<string id="crx_sdk_area.tip">Returns value of the area of a
Parallelepiped (P) or a Triangle (T).</string>
...
</section>
</component>
</stringTable>