Portal Activity Report Iview – Customized way of development
Applies to:
SAP Netweaver 7.0
Summary:
This article provides a way of creating Portal Activity
Report Iview using Portal Application Development that can be used as a
template for generating reports which suits the organization or business
demands.
Author(s): Swaminathan Ramamurthy
Created on: 25th August 2014
Author Bio: Swaminathan Ramamurthy is an SAP Portal Consultant from Cognizant Technology Solutions with more than 5 years of experience. His work has involved application development with Webdynpro Java, PAR; SAP ESS MSS and portal administration.
Introduction
SAP has provided Standard Portal Activity Report Iview template for activity report generation. It has number of customization in itself, like, a hourly report of number of hits or a quarterly report and so on. But when the data to be handled is becoming more, at some point in time theStandard Activity Report produces time out error. i.e., the run time data is huge, so it takes more time to generate report than the standard iview expects.
A Customized Development will help in avoiding these problems and provides options to add more features and customizations necessary. In this article we will be seeing about a way to create Activity Report Iview template using Portal Application Development in NWDI environment and deploy it as SDA file in Portal directly and create report like,
Daily Report – Hourly Basis
Before diving into details, lets see what portal activity report is all about.
How the Portal Activity Report Works
Process Flow
The portal activity report feature is comprised of the following components:
Data Collection Service
The data collection service gathers raw data from the Portal Runtime (PRT) about logged on users and the pages and iViews that were viewed. There is one data collection service on each node in the portal cluster.
The data is stored in the portal database.
The data collection service is started automatically when the portal is installed.
We can turn it off or configure the service from the portal. For more information, see Configuring the Data Collection Service.
Aggregator Application
A program that combines the collected data from all the nodes in the portal cluster and, based on this data, generates aggregated data about users and
their use of portal content. This aggregated data is also stored in the portal database.
The aggregator application deletes the data collection service’s raw data after generating the aggregated data.
The aggregation application is run automatically and you do not have to install or configure it in any way. It is stopped or started whenever the data collection
service is stopped or started.
Portal Activity Report iView Template
A template to create iViews for displaying the aggregated portal activity data.
Note: This article will describe on how to create the Portal Activity Report iView template
Portal Database Tables – Direct Access
The aggregated data will be stored in Portal Database Tables from time to time. We can access the Portal Database using the Java Database
Connectivity (JDBC) standard. It enables us to create and manage DataSource objects from our Portal Application.
Database Overview
The following lists the portal database table, along with
each table’s fields, for holding the aggregated data that is used for creating
portal activity reports
Table Name: WCR_WEBCONTENTSTAT
Purpose: Holds information about the content that was viewed
Table Column Details
Field Name | Data Type | Length | Description |
TIMESTAMPHOUR | Bigint | 8 | The time the content was viewed, a long value equal to the |
AGGREGATIONLEVEL | Nvarchar | 1 | The aggregation level, either h, d, m, q |
COUNTER | Bigint | 8 | For internal use |
PCDURL | Nvarchar | 1024 | The PCD address of the object |
OBJECTTYPE | Nvarchar | 1 | The type of object, either Page or iView |
IMPRESSIONS | Int | 4 | The number of times the object was viewed in the specified |
VISITS | Int | 4 | The number of unique users who saw the object in the |
CUSTOM | Nvarchar | 1024 | The title of the object |
ID | Bigint | 8 | A unique ID for each page in the table, later used for |
Each page is given a unique ID for each aggregation period in which it was viewed. For example, if a page was viewed between 9 and 10 a.m.
and also between 10 and 11 a.m., two records are created in the table, each with has the aggregation level and each with a unique ID field. At the end of
the day, a third record is created, with d as the aggregation level and a different unique ID.
For more information, see Direct Access to Database Tables
Let’s Start the Development!
The steps described here is in conjunction with NWDI. The development will be done as Development Component and deployed to the server as
SDA file.
Creating New DC
- Open NWDS. Go to Development Configuration perspective.Right Click on the SC in which the DC needs to be created and click on
“Create New DC…”
2. A new dialog box will appear. Provide details like Vendor, Name prefix, Name of the DC and Type. The Type of DC we will be using is , Enterprise Portal -> Portal Application Standalone (Packed in SDA) .
If “Portal Application Module” type is selected, the par file generated as a result of building the application, needs to be manually uploaded to Portal.
If “Portal Application Standalone (Packed in SDA)” type is selected, the par file generated as a result of building the application will be packaged automatically as an SDA file which can be directly deployed in the portal from NWDS.
Click on “Next” after providing the details.
3. A DTR activity needs to be created. Click on “New Activity…” and provide the activity name and description and click on “OK”. This will capture all
our development changes to the SC.
Click on ‘Next > “
4. A new dialog box will appear where we can edit the PAR file name that will be generated form this project. Click on “Finish”.
5. A new dialog box, “Add Files to DTR” will appear . It will add portalapp.xml file to DTR. It will be checked by default. Click on “OK”
Select the already created activity, and click on “OK”
Now the DC is created as shown below.
6. Go to “Enterprise Portal” perspective. We can see the DC we have created as shown below.
Let’s take a look on the project structure.
- A set of Jar file references.
- src.api
– folder holds file that will be public (accessible for other project). - src.core
– folder holds file that will be private (accessible only within the project). - Portalapp.xml
– a deployment descriptor file in xml that defines components and services contained in the application and its configuration. It can be located in dist ->
PORTAL-INF.
Creating Abstract Portal Component : DailyReport
7. Now its time to create Portal Components for the project. Right Click on the root folder go to New -> Other…
8. A new wizard for creating Portal Component will open. Select “Portal Application” in the left pane and “Create a new Portal Application Object” in the right
pane and click on “Next >”
9. Select the project under which we are creating the portal component and click on “Next >”
10. Select “Abstract Portal Component” and click on “Next >”
12. Provide the
- Name - DailyReport
- Location – Core
- Class name - DailyReport
- Package name
Click on “Finish”
Select the Activity already created and click on “OK”
The component is created. DailyReport.java file is created under src.core folder. Also , the component will be registered automatically in portalapp.xml file found dist -> PORTAL-INF as shown below.
Configuring portalapp.xml
12. The portalapp.xml file needs to be configured in order to maintain certain application parameters as iView properties to improve the reusability.
For our application the following properties will be maintained under <component-profile> tag. Once it’s maintained, the properties will be available as iView property and the value can be provided for these in Portal while creating the iView.
- PCDURL to monitor – this will hold the pcdurl of the page that will be monitored
- Application Name – this will hold the name of the Application to be displayed in the report
- Report Header – this will hold the suitable description of the Report to be displayed as as Header
The portalapp.xml will now look like this,
Creating Abstract Portal Component : ExcelReport
13. Create a new Abstract portal component, as above and name it as “ExcelReport”. This component will help in exporting the generated report data as Excel Sheet.
Now the project structure will look like as shown below,
Note: ExcelReport component will be called internally from DailyReport , so there is no need to add any property for it in portalapp.xml file
14. To generate Excel Report, POI jar has been used. In NWDI environment, the best practice is to have all external libraries in a separate DC and utilize it in other DC if required.
Note: Make sure the jar file is available in the required DC say EXTLIB and it has been added to its public part ‘assembly’ and ‘libs’
To use the POI jar in the project,
- Add the EXTLIB DC as Used DC in our hrms/content/par/monitor DC as shown below, Go to Portal DC Explorer tab , expand the DC MetaData -> DC Definition -> Used DCs. Right click on ‘Used DCs’ and click on “Add Used DC…”
Select the DC containing jar file under “Inactive” tab and click on “Finish”.
This will enable our DC to use the poi jar functionality.
15. Include code in ExcelReport class
Functionality: This component creates the excel report based on the input parameter. It acts as a centralized component for Export to Excel functionality (daily, weekly and quarterly report)
Short description of the input Parameters passed on from other report components
Parameter | Short description |
PCDURL | Holds the PCD URL path of the |
Name | Holds the iview/page |
Report | Holds the header text for the |
Key | Used to identify the report |
day_xcel | Holds the string values for |
date_time_xcel | Holds the string values for |
users_xcel | Holds the string values for |
hits_xcel | Holds the string values for |
Component details:
Component name: | ExcelReport |
Functionality: |
|
The code for 'ExcelReport' component has been attached.
Creating Helper class : Utility
16. Create a Utility class for
- maintaining code to establish and maintain connections to the database
- storing constant text which are used across all components
Right Click on the project, New -> Other…
17. A new dialog box will appear. Select Java Class and then click on “Next>”
18. Change the Source Folder to src.core and click on “OK”
Click on Browse… and select “src.core” folder
Provide the package and class name and click on “Finish”
Select the activity already created and click on “OK”
Now the project structure will look like this ,
19. Adding Code in Utility.java. The technical details for the class is as follows ,
Short description of the Class variables:
Variable | Short description |
PROPERTY_NAME_PCDURL | Constant String - that holds |
PROPERTY_NAME_APPLICATIONNAME | Constant String - that holds |
PROPERTY_NAME_REPORTHEADER | Constant String - that holds |
ERROR_MSG_NO_PCDURL | Constant String – that holds |
HEADER_COLUMN_DAY
HEADER_COLUMN_DATE_TIME
HEADER_COLUMN_OBJECT_NAME
HEADER_COLUMN_USERS
HEADER_COLUMN_HITS
HEADER_COLUMN_ID | Constant String – that holds |
SEPERATOR | Constant String – that holds |
EXCEL_PARAMETER_PCDURL
EXCEL_PARAMETER_REPORT
EXCEL_PARAMETER_NAME
EXCEL_PARAMETER_KEY
EXCEL_PARAMETER_DAY
EXCEL_PARAMETER_DATE_TIME
EXCEL_PARAMETER_USERS
EXCEL_PARAMETER_HITS
EXCEL_PARAMETER_KEY_VALUE_DAILYREPORT
EXCEL_PARAMETER_KEY_VALUE_WEEKLYREPORT
EXCEL_PARAMETER_KEY_VALUE_QUATERLYREPORT | Constant String – that holds |
REPORT_HEADER_DATE_FORMAT | Constant String – that holds |
Con | Connection Object that is used |
Methods in Utility Class:
Method name: | getConnection () |
Return parameter: | Connection |
Input parameter: | IPortalComponentRequest |
Functionality: | This method helps in creating |
Method name: | closeConnection () |
Return parameter: | Void |
Input parameter: | IPortalComponentRequest |
Functionality: | This method helps in releasing |
The code for 'Utility' helper class has been attached.
20. Lets start creating with our first report - DailyReport.java.
Functionality:
The component creates activity report for the current day on hourly basis.
Technical Details:
Input Parameter | Short description |
PCDURL to monitor | Holds the PCD URL path of the |
Application name | Holds the iview/page |
Report header | Holds the header text for the |
Component details:
Component name: | DailyReport |
Functionality: |
|
The code for 'DailyReport.java' has been attached.
Creating Abstract Portal Component : WeeklyReport and QuaterlyReport
- Similarto ‘Daily Report’, create 2 more abstract components and include relevant logic as required.
- WeeklyReport
- QuaterlyReport
22. The portalapp.xml file needs to be configured for the WeeklyReport and QuaterlyReport in the same way that is done for DailyReport. The complete
portalapp.xml file will contain the code as shown below:
<?xml version="1.0" encoding="UTF-8"?><application> <application-config/> <components> <component name="DailyReport"> <component-config> <property name="ClassName" value="ibm.com.DailyReport"/> </component-config> <component-profile> <property name="PCDURL to monitor" value=""> <property name="personalization" value="no-dialog"/> <property name="type" value=""/> </property> <property name="Application name" value=""> <property name="personalization" value="no-dialog"/> <property name="type" value=""/> </property> <property name="Report header" value=""> <property name="personalization" value="no-dialog"/> <property name="type" value=""/> </property> </component-profile> </component> <component name="ExcelReport"> <component-config> <property name="ClassName" value="ibm.com.ExcelReport"/> </component-config> <component-profile/> </component> <component name="WeeklyReport"> <component-config> <property name="ClassName" value="ibm.com.WeeklyReport"/> </component-config> <component-profile> <property name="PCDURL to monitor" value=""> <property name="personalization" value="no-dialog"/> <property name="type" value=""/> </property> <property name="Application name" value=""> <property name="personalization" value="no-dialog"/> <property name="type" value=""/> </property> <property name="Report header" value=""> <property name="personalization" value="no-dialog"/> <property name="type" value=""/> </property> </component-profile> </component> <component name="QuaterlyReport"> <component-config> <property name="ClassName" value="ibm.com.QuaterlyReport"/> </component-config> <component-profile> <property name="PCDURL to monitor" value=""> <property name="personalization" value="no-dialog"/> <property name="type" value=""/> </property> <property name="Application name" value=""> <property name="personalization" value="no-dialog"/> <property name="type" value=""/> </property> <property name="Report header" value=""> <property name="personalization" value="no-dialog"/> <property name="type" value=""/> </property> </component-profile> </component> </components> <services/></application>
Creating Activity Report iView in Enterprise Portal
22. Now as the development is completed, the development component needs can be Build and Deployed. Once its deployed, it will be automatically be
available on the target portal server where it is deployed.
Note: Once deployed , the associated par which is generated from the project will be available in portal
Go to Content Adminsitration -> Portal Content , right click on a folder and select New-> iView
Select the “Portal Component” option
Select the name of the PAR deployed and click on “Next >”. It will be the name of the DC created. In this document example it will be hrms.content.par.monitor
The Abstract Portal components that have been created in the project will be shown for selection. For example DailyReport can be selected.
Provide the iView general properties and click on “Next>” and then “Finish”.
Select “Open the object for editing” and click on “OK”
3 important iView properties that is configured in portalapp.xml:
- PCDURL to monitor
Provide the pcdurl of the page that needs to be created a report for.
- Application name – Name for the page for which the activity report is being created
- Report Header– Suitable header name for the report e.g., Daily Report
Click on “Save” and then “Preview”.
On Click of “Export to Excel”,
Thus this customized activity report development will help in overcoming the timeout error faced in Standard activity report iView and develop various reports according to the requirements of the business in a more flexible and reusable way.
Related Content
Direct Access to Database Tables