Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Customization of  the report for global applications (Crystal Reports 2008)

When the same application is used by clients located in different countries across the world, we may be required to do some customizations to suit the language/traditional settings used by different countries.

In this article I will tell you how to customize number field, text fields and labels with the example of 2 clients : Client A and Client B. In real life there will be greater diversity in settings required to be implemented, and this is the way to get it started. We shall take for example a simple report displaying Employee Name, Salary and Department. The client type shall be passed to the report at runtime via a report parameter named ClientType which shall have values “A” and “B” for Client A and Client B respectively.

Customization of the numeric data :

There are various kinds of formatting that we apply to numeric data, like, decimal indicator, thousand separator, number of digits after decimal point etc. Let us assume that Client A wants to use “.” as decimal indicator, and “,” as comma separator. On the other hand Client B wants to use “,” as decimal indicator, and “.” as comma separator.

To achieve this we create 2 Report Custom Functions:

Fn_FormatDecimal

Function ( stringvar ClientType, stringvar ParamType)

//Decimal Indicator

If ClientType= "A" then

( if ParamType='DecimalIndicator' then "." );

If ClientType= "B" then

( if ParamType='DecimalIndicator' then "," );

 

Fn_FormatThousand

Function ( stringvar ClientType, stringvar ParamType)

//Thousand seperator

If ClientType= "A" then

( if ParamType='ThSeperator' then "," );

If ClientType= "B" then

( if ParamType='ThSeperator' then "." );

 

Now, right click on the salary data-field, choose Format Field. Go to the Number tab and click on the Customize.. button.

Write the following code for the Decimal Seperator:

stringvar CustomDecimal;

CustomDecimal:=fn_FormatDecimal({?ClientType},"DecimalIndicator");

if CustomDecimal="" then

defaultattribute

else

CustomDecimal;

 

Write the following code for Thousands Seperator , Symbol:

stringvar CustomTh;

CustomTh:=fn_FormatThousand({?ClientType},"ThSeperator");

if CustomTh="" then

defaultattribute

else CustomTh;

 

Customization of the text data :

There are various kinds of formatting that we apply to text data, like font, colour, alignment, indentation etc. In this example let us assume the Client A wants its Text fields to be left aligned, and Client B wants them to be right aligned. Such scenario may arise in real life for Middle- East clients.

This can be achieved by the following steps: Right click on the text-data field, select Format Field, go to the Common tab in the Format Editor, and write the following lines of code for Horizontal Alignment.

if {?ClientType}="A" then crLeftAligned

else crRightAligned

 

Customization of the labels :

It sometimes happens that different clients may access data from the same tables but they might want different labels to be used. In this example let us assume that Client A wants the first column to have the label “Employee Name” and Client B wants the same column to have the label "nom de l'employé". This can be achieved by writing the simple report function below.

 

Fn_LabelEmp

Function (stringvar ClientType)

If ClientType="A" then "Employee Name"

else

"nom de l'employé"

 

The simple text label needs to be replaced by a report formula that calls this report function and passes the clientType to it.

fn_LabelEmp({?ClientType})

 

Note:

  1. If standard customizations are to be implemented for a group of reports, then the best practice would be to convert the report functions mentioned in this article to repository functions so that formatting remains uniform across the application.
  2. If multiple labels across the group of reports are to have customized labels to be displayed, it is better to have a single repository function hold all the customized values. However if the number of labels is very large this might lead to performance issues.
Labels in this area