SAP Knowledge Base Article - Public

1525014 - Sample C# .NET UFL and Localization Formula function

Symptom

  • This sample allows the report designer to set localized string values
  • Attached zip file contains sample C# .NET User Function Library source code as well as a sample report

Environment

Visual Studio .NET

Resolution

 

  • To use this UFL you need to register it with VS .NET
  • Use the regasm command line tool (C:\Windows\Microsoft.NET\Framework\v2.0.50727\RegAsm.exe)
  • This UFL only works with Crystal Reports 2008 Service Pack 1 and higher
  • For more details see the readme.txt file included in the attached zip file

Also Note:

To change the Class Name so the function name (DotNetSampleClass) is not listed in Crystal Report Designer do the following:

  1. Click on the View menu in .NET IDE and select Show Class View.
  2. Then right click on the class and select Rename.
  3. The delete all but "CRUFL"
  4. Click the OK button and yes to the next prompt to confirm the name change.
  5. Do the same for the "Class Test" and change it to something like "Fnt".

Now you will see the function named: Fnt StringLength.

To be able to use the UFL in CR Designer you need to tell the Designer to use the same framework by doing the folowing:

To see this new UFL in Crystal report Designer do the following:

  • Crystal Report Designer 2011/2013 is a 32 bit app so the UFL MUST be compiled in x86 mode. If you plan to use the UFL in a 64 bit application then you need a separate 64 bit version:
  • Copy the file and for CR 2008 place it in this folder:
  • C:\Program Files (x86)\Business Objects\BusinessObjects Enterprise 12.0\win32_x86
  • For CR 2011/2013 in this folder:
  • C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86
  • CR for VS is the only 64 bit runtime we have except for BI 4.x also may require it. Depending on the CR Processing Server it may need the 64 bit UFL and 32 bit UFL.

For 32 bit App:

    • C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86
    • C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86

64 bit App:

    • C:\Program Files (x86)\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win64_x64
    • C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x64

To be able to set Crystal Report Designer to use the same Framework you created the UFL in you must tell CR Designer whcih one to use by doing the following:

Create a file called:

crw32.exe.config

And paste this into it:

<?xml version ="1.0"?>

<configuration>

  <startup useLegacyV2RuntimeActivationPolicy="true" >

    <supportedRuntime version="v4.0" />

  </startup>

</configuration>

Change the "supportedRuntime version" to what ever framework you are compiling your UFL in.

Save this file into the same location as crw32.exe:

For CR 2011/2013:

C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86

And for CR 2008:

C:\Program Files (x86)\Business Objects\BusinessObjects Enterprise 12.0\win32_x86

Now you should see your functions in the list in CR Designer.

 

See Also

Keywords

.NET UFL UNICODE String UFL user function library visual studio VS , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , How To

Product

Crystal Reports 2008 V0 ; Crystal Reports 2008 V1 ; SAP Crystal Reports 2011 ; SAP Crystal Reports, developer version for Microsoft Visual Studio

Attachments

CRUFLDotNetSample.zip