Business Intelligence – Oracle

Oracle BI EE 10.1.3.4.1 – Writebacks to Essbase – Using JAPI and Custom HTML – Part 1

Posted by Venkatakrishnan J on May 25, 2009

Considering the amount of expectations surrounding the BI EE and Essbase connectivity, i thought it would make a lot of sense to blog about another interesting piece of the Essbase and BI EE integration i.e Writebacks to Essbase from BI EE. Actually i have seen this question being asked by customers/users in quite a few internal presentations that i have been involved recently. Writebacks to Essbase from BI EE is not supported by default. Having said that one can create a custom solution to enable a writeback to an Essbase cell. We shall see one approach of doing this today.

As you would probably know, Writebacks to a relational source from BI EE is supported through custom XML messages. Unfortunately, as of this release, this method cannot be reused for non-relational sources. Basically our requirement is pretty simple. In a BI EE report (reporting against an Essbase source), the end user should have the ability to enter custom values and update the corresponding intersections back in Essbase. The below screenshot explains the requirement pretty clearly.

The high level architecture diagram to enable these writebacks is given below

The high level flow is, for every cell update, the end user will enter the new value and then will click on the update button. That will pass on the parameters to a JSP page using the HTML Form GET method. The JSP will accept the parameters and will in turn pass on the values to the JAPI. The JAPI will then update the Essbase cell. To illustrate this, we shall use the default Demo->Basic cube. Remember the fact that one cannot use the write backs textboxes directly as currently BI EE does not provide a means of referencing the updated/entered value in a cell outside of the XML template. So, we would need to write our own custom HTML to generate textbox and the update buttons.

Import the Demo Basic cube into the repository and create the BMM and presentation layers by drag and drop. Change the physical and the BMM layer aggregations(of the all the measures for which you want to enable writebacks) to SUM instead of Aggr_External. The main reason for doing this is to ensure that we can use string manipulation functions like concatenation from Answers. For more details on each of these aggregations check my blog entries here, here, here and here.

Now, lets go to JDeveloper and create a simple JSP page. Use the below code in the JSP. You can customize this to your needs.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="java.io.*" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Map.Entry" %>
<%@ page import="java.util.jar.Attributes" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="com.essbase.api.base.*" %>
<%@ page import="com.essbase.api.dataquery.*" %>
<%@ page import="com.essbase.api.session.*" %>
<%@ page import="com.essbase.api.datasource.*" %>
<%@ page import="com.essbase.api.domain.*" %>
<%@ page import="com.essbase.api.metadata.*" %>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>WriteBackEssbase</title>
  </head>
    <body>
		<font size="5"><%="WriteBack Started" %></font>

<%

        String s_userName = "admin";
        String s_password = "password";
        String s_olapSvrName = "localhost";
        String s_provider = "http://localhost:13080/aps/JAPI";

        try
        {
        IEssbase ess = IEssbase.Home.create(IEssbase.JAPI_VERSION);
        IEssDomain dom = ess.signOn(s_userName, s_password, false, null, s_provider);
        IEssOlapServer olapSvr = (IEssOlapServer)dom.getOlapServer(s_olapSvrName);
        olapSvr.connect();
        IEssCubeView cv = dom.openCubeView("Data Update Example",s_olapSvrName, "Demo", "Basic");

        String v_Market = request.getParameter("p_Market");
        String v_Product = request.getParameter("p_Product");
        String v_Accounts = request.getParameter("p_Accounts");
        String v_Scenario = request.getParameter("p_Scenario");
        String v_Year = request.getParameter("p_Year");
        String v_Value = request.getParameter("p_Value");

        IEssGridView grid = cv.getGridView();
        grid.setSize(2, 5);
        grid.setValue(0, 1, v_Market);
        grid.setValue(0, 2, v_Product);
        grid.setValue(0, 3, v_Accounts); ;
        grid.setValue(0, 4, v_Scenario);
        grid.setValue(1, 0, v_Year);

        cv.performOperation(cv.createIEssOpRetrieve());
        System.out.println("\nData Cell at 2nd-row, 2nd-column: " + grid.getValue(1,1).toString());
        System.out.println ("Market: "+v_Market+" Product: "+v_Product+" Accounts: "+v_Accounts+" Scenario: "+v_Scenario+" Year: "+v_Year+" Value: "+v_Value);

        int row = 1, col = 1;
        if (grid.getCellContentType(row, col) ==
                IEssGridView.CELL_CONTENT_TYPE_DOUBLE) {
            IEssValueAny val = grid.getValue(row, col);
            double dblVal = val.getDouble();

            grid.setValue(row, col, Double.valueOf(v_Value).doubleValue());
        } else if (grid.getCellContentType(row, col) ==
                IEssGridView.CELL_CONTENT_TYPE_MISSING) {
            grid.setValue(row, col, Double.valueOf(v_Value).doubleValue());
        }

        IEssOpUpdate opUpd = cv.createIEssOpUpdate();
        cv.performOperation(opUpd);

        }catch (EssException x){
            System.out.println("ERROR: " + x.getMessage());
        }
%>
<font size="5"><%="WriteBack Ended" %></font>
		<font size="5"><%="WriteBack Ended" %></font>
        </body>
</html>
<%
    //response.sendRedirect("http://localhost:9704/analytics");
%>

I would not explain this in detail as the JSP is self-explanatory. But there is one aspect to writebacks using JAPI that one would have to be aware of. Whenever JAPI is used for writebacks ensure that you have a IEssGridView which basically visualizes your output as an Excel add-in grid. The rows and columns are numbered in an increasing order from zero.

The code snippet that actually does the writeback is given below

Once this is done, this JSP would have to be deployed on a web server that is accessible to BI EE. In order to accomplish that, create a custom WAR profile which would basically contain all the dependent jar files and also the manifest related information.

Then deploy this WAR file on the same application server as BI EE (or OC4J).

Once the deployment is done, test the jsp page by passing the url as shown below

http://localhost:9704/WriteBack/WriteBack.jsp?&p_Value=2000&p_Market=Market&p_Product=Product&p_Accounts=Accounts&p_Scenario=Actual&p_Year=Qtr1

Once this is done, lets create a BI EE report containing all the dimensions. Remember that for writebacks to work in Essbase, we would need a value/member from every dimension. Create a custom column and in the custom colum enter the formula as shown below

'<form name="input" action="http://localhost:9704/WriteBack/WriteBack.jsp">
<input type="text" name="p_Value" size="10"/>
<input type="submit" value="Update" />
<input type="hidden" name="p_Accounts" value="Sales" />
<input type="hidden" name="p_Year" value="'||"Year"."Gen2,Year"||'"/>
<input type="hidden" name="p_Market" value="'||Market."Gen2,Market"||'"/>
<input type="hidden" name="p_Product" value="'||Product."Gen1,Product"||'"/>
<input type="hidden" name="p_Scenario" value="'||Scenario."Gen2,Scenario"||'"/>
</form>'

And change the column format to HTML.

Basically what the formula above does is, it create an HTML input field in the report itself. One parameter p_Value would be obtained from the value of the textbox and the remaining hidden form parameters will be used for passing the dimension member attributes to the url.

If you go to the report now, you can alter the existing values and on submit, these values would be submitted back to Essbase.

The same methodology can be used for writing data back into Oracle OLAP as well. This is one method of doing writebacks. There is one more method as well wherein one can use the Writeback template itself. I will discuss that in future. But for now, the above should give an idea of how Writebacks can be enabled in BI EE against Essbase data sources. There are quite a few moving parts. But again these are required due to the nature of the connectivity as of today.

2 Responses to “Oracle BI EE 10.1.3.4.1 – Writebacks to Essbase – Using JAPI and Custom HTML – Part 1”

  1. Hi Venkatakrishnan,

    Excellent post – food for thought in relation to the standard writeback functionality.
    One thing I’d need to look closer at is the security around this solution – both from username/password connectivity to Essbase via JAPI and authorization to the JSP itself. Of course we can put additional code in the JSP to handle these aspects.

    Great stuff.

    Regards,
    Gareth

  2. Merlyn Samon said

    hi,
    is it possible to add survey forms in BIEE dashboards? we can use writeback as a workaround. but, we are trying to explore using html and javascript to create surveys for users to fill up. Since we couldn’t create radio buttons or listbox using writeback, maybe we can use html and javascript instead. would that be possible? would you know any site that would explain how this could be done. thanks very much!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: