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
0 Kudos

1)Crystal Report -> Setting Horizontal Alignment of fields dynamically:

Benefit:

Horizontal Alignment formatting property can be used for the dynamic nature reports, where field values are shown dynamically based on required condition, which in turn will reduce the overload of creating many formulae to achieve the alignment.

How to use:

To change the Horizontal Alignment of the database field/formula field follow the below mentioned steps:

1) Right click on the field.
2) Click on Format Field Option.
3) Select the Common Tab.
4) Click the formula editor in front of Horizontal Alignment and add the setting required.
5) Following are the Alignment constants available:

Constant                              Description

crDefaultHorAligned           Set the default alignment to horizontal.
crLeftAligned                     Align to the left.
crRightAligned                   Align to the right.
crCenteredHorizontally       Center horizontally.
crJustified                        Set alignment to be justified

For Example:   If a specific formula in the report returns distinct values at run time, may be string, date (converted to string) or number  (converted to string) and based on the values returned; alignment needs to be set then following condition can be used:

if currentfieldvalue= "field.salary" then crRightAligned
elseif currentfieldvalue="field.name" then crLeftAligned
elseif currentfieldvalue="field.date" then crCenteredHorizontally

 Hence using above mentioned Horizontal Alignment property, additional formula creation can be avoided.

Note: The above property is available only for Database Field & Formula field, not for Static text box field.

2)Crystal Report -> Use of ToText Function:

Benefit:

When Sorting or Grouping is required based on return type of any Parameter value, ToText function can be used to convert different type of database field (i.e. number, date etc) to same type i.e. String.

How to use:

For Example: The parameter name used in the report for dynamic sorting is “SORTFIELD”, then following formula can be created to achieve dynamic sorting:

If SORTFIELD= “Name” then field.name
Elseif SORTFIELD=”Amount” then ToText(field.Amount,”############.##”)
Elseif SORTFIELD=”Date” then ToText(field.Date,”yyyyMMdd”)

Where Database field type is:
field.Name is string
field.Amount is Number (Above # is replaced by blank space)
field.Date is Date (Above yyyy is for year (e.g. 2011) , MM is for month (09) and dd for Date (23).

  Hence the return type of the formula will be same as STRING, even though different type of database field is being used.

Labels in this area