Recently, I had to prepare the “Document Access Report Sample” [Enhancing Customer Reports with Commands and Parameters] to be used on the production server. Here I am going to share a couple of tips that I found useful during the configuration of this KM Report. They may help you if you need to make a custom KM report.
A. How to change the report column names in the KM report header?
When the first time you deploy the report sample, the report result header looks like this:
The custom properties that are used in the report are shown as the property real names in the columns and in the filter dropdown. To modify the names in the columns and the filter dropdown there are two ways. The first way is to implement the getDisplayName method of IReport interface like how it is done in the sample. However, for some reason this method is not being called by KM Report UI Component and the display names are set to the property names (It might be a small bug in the Report Result Control, release EP7.0.6.) If it doesn’t work for you too, you can use the following configuration process as a clean work around.
The property names like lastaccess, access_count, and unique_count are used in the sample report. These names appear at the table header by default. To show the display names from the text resource bundle, you just need to define the properties in the KM property metadata service configuration and assign them to the resource bundle file. To define the properties and the labels in the KM Property Metadata, follow the steps:
1. Open KM Content Management under System Administration->System Configuration
2. Open Global Services
3. Open Property Metadata (Property Definition)
4. Add the Namespace
4.1. Open Namespaces
4.2. Click on the “New” button
4.3. Give a unique name to the namespace alias
4.4. The namespace should be the property namespace that is used in the report, in the case of the example, it is “http://sap.com/km/stats”
4.5. Return to the Property Metadata page
5. Add the Metadata Extension
5.1. Open Metadata Extensions
5.2. Click on the “New” button
5.3. Choose a unique name for your Extension
5.4. The bundle file can be a resource bundle file in the report package or any resource bundle file that is deployed in a par file. For the sample report, it should be “com.sap.netweaver.km.stats.report.DocumentAccessReport”.
5.5. Return to the Property Metadata page
6. Add the custom property (repeat this step for all the custom properties that you have in the report)
6.1. Open Properties
6.2. Click on New button.
6.3. Enter a unique ID for the property
6.4. Enter the name of the property in the Property ID field
6.5. Select the Namespace Alias that you just created from the list
6.6. Select the appropriate type for the property from the list
6.7. Select the Meta Data Extension that you just created
6.8. Fill the key for label with the key in the resource bundle file which is DocumentAccessReport.properties for this report (e.g. use report.disp.lastaccessed for lastaccessed property.)
6.9. Leave other fields unchanged
Now the report component retrieves the property labels from the keys in the resource bundle that are specified in the Property Metadata service and it will look like this:
You can also export all the property metadata that you create to an xml file using the Export feature and import them into your production server.
B. How to modify the xml output of the report?
The report users might also want to use the xml output. This xml file is rendered by an XSLT file that is common for all the reports. However, you can specify one XSLT file for each report in EP7.0 and probably some earlier releases. The default XSLT file is stored in the root of reporting repository (/Rerporting) and its name is “report-result.xslt”. The first step is to download this file and make your changes based on your requirements. One of the changes that you most likely need is to modify the column names again.
After modifying the XSLT file, upload it with a new name into the same location or any location.
Now there are two ways to use this new XSLT file in the report xml output. The first way is through the Content Configuration. Here are the steps to assign the XSLT file to a report:
1. In the KM Configuration->Content Cofiguration, Open Content Managers
2. Click on Show Advanced Options
3. Click on Reports under related topics
4. Select your report (DocumentAccessReport for the sample report)
5. Click on the Edit button
6. Put the uploaded XSLT file path (e.g. /reporting/new-report-result.xslt) in the “Result XSLT” field.
7. Click on OK!
We have to repeat these steps when installing the report on another server. However, in the second way this path will be automatically deployed with the other configuration parameters within the par file. In the report project under folder /src.config/install/data/cm/repository_managers/reports there is a file named documentaccess_report.co.xml which contains the report properties:
You can add the result XSLT path in this XML config file by adding the following line in the Configurable node with resultXslt (case sensitive) property:
To make sure the property is set properly for the report, you can view the report properties in the reports table (go to step 3). If the path is not there try to delete the report from thelist and deploy the par file again. It will create the report in the list with all its properties.