Examples with selected exercises
Elementary inquiry report by month
Objective:
Selection of inquiries according to criteria entered by the user; list of inquiries by month with monthly totals.
Complex search
First create a complex search called JR_Inquiries_by_month.
In this, create a search with the same name, JR_Inquiries_by_month, with the fields Match Code, Sales Date, Prospect of Success Key, Project Value. Remember that all fields must also be passed to the report.
Save the search.
Report
Switch to the JasperReports mask and create a new report named Inquiries_by_month.
Set the following as a search: JR_Inquiries_by_month.
Press the Save button. At this point, CURSOR-CRM/EVI generates a first draft report.
Press the Edit button. Now the iReport Designer opens and you can continue to edit the draft report.
Weighted project value
This is the expected value of the project value, i.e. the product of the prospect of success and the project value.
Create a new text field and enter the following expression (you can also find it above under Examples of expressions):
$F{Projectvalue} * $F{ChanceSuccessKey_KeyName} / 100
Make sure that the result type is set as Double and the style as Decimal in the properties of your field.
You can use the following expression as the column header: $R{Expectation}. This identifier occurs relatively often, which is why it is already contained in CURSOR-CRM.
Sorting
Sorting by the 'Salesdate' field. Remember: the sorting can be found under the database query, Sort options button.
Grouping
For grouping by month, we calculate the first day of the same month from the actual sales date (see Examples of expressions).
Group name: Month.
Group expression:
new Date( $F{Salesdate}.getYear(), $F{Salesdate}.getMonth(), 1 )
Put the $F{Salesdate}
field in the group header ('MonthHeader')
and format it so that only month and year, not the exact day, appear. This way you get the month without calculations, only with formatting.
Monthly totals
Create a new variable named Inquiry_Value_Monthly_Total.
Set:
Variable name: Inquiry_Value_Monthly_Total
Variable class: java.lang.Double
Calculation type: Total
Reset type: Group (means: you want to calculate the total for each month)
Reset group: Name of the group, in this case month.
Expression:
$F{Projectvalue}
Initial Value Expression: can obviously be left blank.
You can now output this variable in the report footer.
You can also create a variable for the weighted project value. This differs from the Inquiry_Value_Monthly_Total variable by the expression, where you note the expression for the weighted inquiry value again.
Total amounts
To do this, you must create two more variables. They are constructed like the monthly totals, but Reset type is now report, so the total adds up all the numbers.
Customizing the business partner portrait
In this example, we assume that the Freetext21
field has been released for users in the business partner entity by Customizing. It was defined as a freely definable field, not as a key field.
The field should now appear in the business partner portrait.
Since the business partner portrait is read-only, you must first create a copy. The copy button in the JasperReports mask is used for this purpose.
Your new report also includes a new search. You can see what the search is called in the JasperReports mask.
Open this new search in the Complex Search mask.
Open the main search and change it as follows:
Right-click, add condition, select field
Check the Export in search result checkbox
Save search
Save complex search
Then return to the JasperReports mask and open the report for editing.
In Jasper, use the field list (menu item: Data / Report Query) to determine the CURSOR-CRM/EVI internal field name (it is 'Freetext21').
Insert a new text field. Set the following properties:
Expression:
$F{Freetext21}
Style: Text
Insert another text field as field identifier with the following properties:
Expression:
$R{Freetext21}
Style: Label
Now save the report and check the "Reporting Menu", "Printing Button" and "Default Mask Report" checkboxes. In the original business partner portrait, remove the corresponding settings.
From now on, your CURSOR-CRM /EVI installation uses your own copy of the business partner portrait and no longer the original from CURSOR Software AG.
Calculating the duration of a business process
This is an example of "totals of totals".
Let us assume that you have several activities for a business partner (or other entity). One is marked as START (in the start key), another as END. You want to determine the duration of this process.
Start date variable:
Data type: Timestamp
Calculation type: Maximum
Expression:
$F{ContactReason_KeyName}.equals( "ANFANG" )? $F{StartDate}: null
Reset: Business partner group
End date variable:
Data type: Timestamp
Calculation type: Maximum
Expression:
$F{ContactReason_KeyName}.equals( "ENDE" )? $F{StartDate}: null
Reset: Business partner group
Duration variable:
Data type: Double
Calculation type: Maximum
Expression:
$V{EndDate} - $V{StartDate} (see above under date difference)
Reset: Business partner group
Total duration variable:
Calculation type: Total
Counter type: group; counting group: business partners (special properties that are important for this purpose and are rarely used)
Expression:
$V{Dauer}
Reset: Report