Quantcast
Channel: SCN : All Content - SAP Enterprise Portal
Viewing all articles
Browse latest Browse all 3876

Portal Activity Report Iview – Customized way of development

$
0
0

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

 

pic1.png

 

 

 

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
  number of milliseconds since January 1, 1970, 00:00:00 GMT.


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
  period (hit count)


VISITS


Int


4


The number of unique users who saw the object in the
  specified period


CUSTOM


Nvarchar


1024


The title of the object


ID


Bigint


8


A unique ID for each page in the table, later used for
  retrieving the users who saw the page

 

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

  1. 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…”

pic1.jpg

    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) .

pic2.jpg

 

 

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 > “

pic4_1.jpg

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”.

pic.jpg

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”

 

pic.jpg

 

Select the already created activity, and click on “OK”

 

  Now the DC is created as shown below.

 

pic.jpg

 

6. Go to “Enterprise Portal” perspective. We can see the DC we have created as shown below.

 

pic.jpg

 

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.

 

pic.jpg

 

 

 

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…

pic.jpg

 

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 >”

pic.jpg

9. Select the project under which we are creating the portal component and click on “Next >”

pic.jpg

10. Select “Abstract Portal Component” and click on “Next >”

 

pic.jpg

 

12. Provide the

    • Name - DailyReport
    • Location – Core
    • Class name - DailyReport
    • Package name

    pic.jpg

      Click on “Finish”

     

      Select the Activity already created and click on “OK”

    pic.jpg

    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.

    pic.jpg

     

     

    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,

      pic.jpg

       

       

      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.

      pic.jpg

       

        Now the project structure will look like as shown below,

      pic.jpg

       

      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…”

      pic.jpg

        Select the DC containing jar file under “Inactive” tab and click on “Finish”.

       

      pic.jpg

        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
        page/iview to monitor to be displayed in excel report


      Name


      Holds the iview/page
        application name that will be displayed in the excel report


      Report


      Holds the header text for the
        excel report


      Key


      Used to identify the report
        component (DailyReport / WeeklyReport / QuaterlyReport ) that gives a call to
        ExcelReport


      day_xcel


      Holds the string values for
        “Day” field concatenated using “ilP”


      date_time_xcel


      Holds the string values for
        “Date/Time” field concatenated using “ilP”


      users_xcel


      Holds the string values for
        “Users” field concatenated using “ilP”


      hits_xcel


      Holds the string values for
        “Hits” field concatenated using “ilP”


       

       

      Component details:

       

       


      Component name:


      ExcelReport


      Functionality:


      • This component uses the above mentioned input
          parameters and create an Excel Report
      • The API used for creating excel report is POI.
      • The value in “Key” variable differentiates the
          type of excel report to be generated , for eg., daily or weekly or quarterly
          report
      • Once the excel report is ready , the
          httpservlet response is used for providing an option for the user to download
          / view the excel locally .


       

       

      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…

         

        pic.jpg

        17. A new dialog box will appear. Select Java Class and then click on “Next>”

        pic.jpg

        18.  Change  the Source Folder to src.core and click on “OK”

        pic.jpg

          Click on Browse… and select “src.core” folder

         

         

        pic.jpg

          Provide the package and class name and click on “Finish”

        pic.jpg

         

          Select the activity already created and click on “OK”

          Now the project structure will look like this ,

        pic.jpg

         

        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
          the string value of the parameters that are customized in iview level i.e.,
          PCDURL to monitor


        PROPERTY_NAME_APPLICATIONNAME


        Constant String - that holds
          the string value of the parameters that are customized in iview level i.e.,
          Application name


        PROPERTY_NAME_REPORTHEADER


        Constant String - that holds
          the string value of the parameters that are customized in iview level i.e.,
          Report header


        ERROR_MSG_NO_PCDURL


        Constant String – that holds
          the string value of the error message to be displayed when 'PCDURL to
          monitor' property is not provided value in iview level


        HEADER_COLUMN_DAY

         

          HEADER_COLUMN_DATE_TIME

         

          HEADER_COLUMN_OBJECT_NAME

         

          HEADER_COLUMN_USERS

         

          HEADER_COLUMN_HITS

         

          HEADER_COLUMN_ID


        Constant String – that holds
          the string value of the Column Header names for the report


        SEPERATOR


        Constant String – that holds
          the string that is used as a Separator which helps in transporting the values
          from Report to Excel


        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
          the string value of the parameters that is passed from Report to Excel
          Component


        REPORT_HEADER_DATE_FORMAT


        Constant String – that holds
          the string value which resembles the Date Format that is used in Report
          Header


        Con


        Connection Object that is used
          by all Report Components

         

          Methods in Utility Class:

         

         

         


        Method name:


        getConnection ()


        Return parameter:


        Connection


        Input parameter:


        IPortalComponentRequest
          request


        Functionality:


        This method helps in creating
          the connection to the Datasource and return the connection object to the
          requested component

         

         

         

         


        Method name:


        closeConnection ()


        Return parameter:


        Void


        Input parameter:


        IPortalComponentRequest
          request


        Functionality:


        This method helps in releasing
          the resources by closing the connection object


         

        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
          page/iview to monitor


        Application name


        Holds the iview/page
          application name that will be displayed in the report


        Report header


        Holds the header text for the
          report

         

        Component details:

         

         

         


        Component name:


        DailyReport


        Functionality:


        • This component need the parameter value for
            “PCDURL to monitor”  for successful
            generation of report
        • The output report is displayed using HTML
        • This Component uses Utility class for
            establishing the connection to the portal database.
        • It aggregates the data for the current day on
            per hour basis and displays it in HTML table format.
        • It also stores the report data that is
            generated into variables like day_xcel, date_time_xcel, users_xcel, hits_xcel
            which are passed to ExcelReport Component in order to generate the Excel
            Report.
        • The Component also provides a HTML button
            “Export to Excel”
        • The Component uses Utility class for closing
            the connection once the report is generated.



        The code for 'DailyReport.java' has been attached.

         

        Creating Abstract Portal Component : WeeklyReport and QuaterlyReport

          1. Similarto ‘Daily Report’, create 2 more abstract components and include relevant logic as required.

         

          • WeeklyReport
          • QuaterlyReport

          pic.jpg
            pic1.jpg

           

          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

           

          pic.jpg

           

          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

          pic.jpg

           

          The Abstract Portal components that have been created in the project will be shown for selection. For example DailyReport can be selected.

          pic.jpg

           

          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.

          pic.jpg

           

           

          • Application name – Name for the page for which the activity report is being created

          pic.jpg

           

          • Report Header– Suitable header name for the report e.g., Daily Report

          pic.jpg

            Click on “Save” and then “Preview”.

          pic.jpg


           
          On Click of “Export to Excel”,

          pic.jpg


           
          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

           

           

          Portal Activity Report

           

           

          Creating Portal Application


           
           
           
           
           
           
           





          Viewing all articles
          Browse latest Browse all 3876

          Trending Articles



          <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>