Tuesday, March 16, 2010

Enabling SSL for BI Publisher Standalone

How to enable SSL (Secure Sockets Layer) for my BI Publisher Server installed with OC4J standalone ?

SSL is a cryptographic protocols that provides a encrypted therefore secured communications over internet. This can be enabled for your BI Publisher Server to secure the communication between the server and the clients.

I’m sure many of you have installed BI Publisher as a part of Oracle BI EE suite or as just a BI Publisher Server standalone following the standard installation with the installer. The standard installation installs an embedded OC4J server and deploy BI Publisher Server on the OC4J server. In this deployment architecture you don’t have any HTTP server. OC4J Server directly interacts with clients http requests and returns response to the clients for the BI Publisher Server.

Today, I will talk about how to enable the SSL for such configuration, which is that BI Publisher Server standalone deployed on OC4J standalone. I will focus only on enabling SSL communication.

Here is a list of the brief steps that you need to perform.

  • Create a Keystore
  • Create and Update secure-web-site.xml
  • Register the secure-web-site.xml in server.xml
  • Test

Create a Keystore

A keystore stores certificates, including the certificates of all trusted parties, for use by a program. Through its keystore, an entity such as OC4J (for example) can authenticate other parties, as well as authenticate itself to other parties. In Java, a keystore is a java.security.KeyStore instance that you can create and manipulate using the keytool utility that is provided with the Sun Microsystems JDK. The underlying physical manifestation of this object is a file.

Here are the steps to create the keystore.

  1. Change the directory to ORACLE_HOME/j2ee.

  2. Create a keystore with an RSA private/public keypair using the keytool command. In this example, we generate a keystore to reside in a file named mykeystore, which has a password of 123456 and is valid for 365 days, using the RSA key pair generation algorithm with the following syntax:

% keytool -genkey -keyalg "RSA" -keystore mykeystore -storepass 123456 \ -validity 21

Note:

  • The keystore option sets the filename where the keys are stored.
  • The storepass option sets the password for protecting the keystore.
  • The validity option sets number of days the certificate is valid.

    The keytool prompts you for more information, as follows:

    What is your first and last name? [Unknown]: Kan Nishida

    What is the name of your organizational unit? [Unknown]: Consulting

    What is the name of your organization? [Unknown]: Oracle

    What is the name of your City or Locality? [Unknown]: New York

    What is the name of your State or Province? [Unknown]: NY

    What is the two-letter country code for this unit? [Unknown]: US

    Is <CN=Kan Nishida, OU=Consulting, O=Oracle, L=New York, ST=NY, C=US> correct? [no]: yes

    Enter key password for <mykey> (RETURN if same as keystore password):

    Always press RETURN for the key password. In the OC4J 10.1.3 implementation, the keystore password must be the same as the key entry password.

    The mykeystore file is created in the current directory. The default alias of the key is mykey.

    Create and Update secure-web-site.xml file

    1. If you do not have a secure-web-site.xml file, copy the default-web-site.xml to ORACLE_HOME/j2ee/home/config/secure-web-site.xml (by convention).
    2. Open the secure-web-site.xml and add secure="true" to the <web-site> element, as follows:

      <web-site port="4446" display-name="Default OracleAS Containers for J2EE Web Site" secure="true" >
      ...

      </web-site>


    3. Change the <web-site> port setting to some available port. For example, port="4443". (To use the default of 443, you have to be a super user.)
    4. Add the following under the <web-site> element to define the keystore and password.

      <ssl-config keystore="your_keystore" keystore-password="your_password" />


      Where your_keystore is the path to the keystore—either absolute, or relative to ORACLE_HOME/j2ee/home/config (where the Web site XML file is located)—and your_password is the keystore password. For example:

      <!-- Enable SSL -->
      <ssl-config keystore="../../keystore" keystore-password="123456"/>

      Register secure-web-site.xml file in server.xml

      Add the following line in server.xml:

      <web-site path="./secure-web-site.xml" />

      Save the changes and restart OC4J server to reflect the changes.

      Access to BI Publisher Server for Testing

      Now all the settings are done. Let’s test. You should be able to use ‘https’ to access to your BI Publisher.

      https://hostname:port/xmlpserver



      where the port number is the one you set in the secure-web-site.xml file.

      e.g.
      https://knishida-lap.us.oracle3.com:4446/xmlpserver

      Snap5

      Now OC4J listens for SSL requests on one port (in this example 4446) and non-SSL requests on another (the default is 9704). You can disable either SSL requests or non-SSL requests, by commenting out the appropriate *-web-site.xml pointer in the server.xml configuration file:

      <web-site path="./secure-web-site.xml" /> - comment this to remove SSL

      <default-site path="./default-web-site.xml" /> - comment this to remove non-SSL

      Conclusion

      Well, it’s pretty simple right?. But of course if you want to really secure then you can do more in the configuration. Also if you have a http server involved, which is a typical architecture with Oracle Application Server, then it requires extra steps. You can take a look at OC4J Security Guide 10.1.3 for the detail. Also, if you need to integrate with Oracle BI EE, which is SSL enabled then there will be more steps, though they are documented in the Oracle BI EE Deployment Guide.

    1. How to Migrate BI Publisher Reports to Production?

      migration

      How can I migrate all the reports developed at a development instance to a testing or production instance with BI Publisher Server ?

      This is very typical thing you as an administrator or reports developer would concern. The good news is, migrating BI Publisher reports from one instance to anther is pretty simple. All the reports are stored in a BI Publisher repository, which is typically on a file system or inside Oracle XML database. So, all you need to do is to copy the BI Publisher repository from the source system and paste it to the target system. Here is a diagram that shows the migration.

      Diagram

      Of course you need to have BI Publisher server installed and up-and-running at the target system before the migration. Either if your repository is on the file system or XML DB, this process would be pretty much the same. I’ll talk about the process assuming that the repository is on the file system in this post.

      What is BI Publisher Repository?

      So what is really the BI Publisher repository. It stores the following types of contents and information.

      • Reports
      • Server Configuration
      • Translation

      BI Publisher Repository Screenshot

      clip_image002

      It not only stores the reports but also contains all the configuration related information. Let’s take a look at the detail for each. 

      1. Reports

      Under ‘Reports’ folder in the repository all the reports are organized in a folder based structure, which is in the same way that you see in the BI Publisher Enterprise server’s reports list UI page. Each report has its own folder, which contains one report definition file (.xdo) and report templates such as .rtf or .pdf.

      1.1. Reports Definition

      All the information for the BI Publisher reports are stored in the reports definition files which has a file extension as ‘.xdo’ It stores the information like sql query, report name, parameter name, list of values, template name, reports translation, bursting setting, report property, etc.

      1.2. Reports Template

      When you work on reports development most of the work is done within the report layout templates such as RTF Templates, PDF Templates, to design the reports layout and formatting. Once you complete the development you upload them to the BI Publisher Enterprise Server and register them as layout templates for each report. These uploaded report templates are also stored in the BI Publisher repository and resides along with the reports definition file (.xdo) in a same report folder.

      2. Enterprise Server Configuration

      All the BI Publisher server configuration related information is also stored in the BI Publisher repository. The configuration information includes the following.

      • Server Configuration
      • Security
      • Scheduler
      • Delivery
      • Data Source

      These information is stored under Admin folder within the repository.

      3. Translation

      There are two types of the translation. One is a translation for the BI Publisher Server product UI. BI Publisher Server supports 28 languages translations (includes English) for its UI. All the translated strings are stored in a set of XLIFF files and each language has its own XLIFF file to store the translation. These translations are located under Admin/Translation.

      And another is a translation for the reports. If you are a French and open a report you want to see all the text are written in French. If you are a German you expect the same way. BI Publisher separates the translation from the report so you don’t need to create multiple reports for each language. Instead, you can just have one report and multiple translation XML files (XLIFF format), which contains only the translatable strings. These translations are located along with each report.

      Now you get an idea of the BI Publisher Repository. Let’s start the migration.

       

      Migration Process Overview

      Before you start the migration, again, ensure the BI Publisher Server exists at a target instance! The migration process has two parts.

      1. Migrate BI Publisher repository
      2. Perform Post-Migration Configuration

      1 Migrate BI Publisher Repository

      First, we need to obtain the repository from the source instance. Then locate it to the target BI Publisher repository.

      1.1 Obtain BI Publisher Repository from a Source Instance

      The screen below shows the root directory of the BI Publisher repository

      clip_image002[4]

      1. Identify the BI Publisher Repository at the source instance
        You can find this information in a BI Publisher’s system configuration file, which can be found at %J2EE_HOME%/applications/xmlpserver/xmlpserver/WEB-INF/xmlp-server-config.xml (e.g. C:\OracleBI\oc4j_bi\j2ee\home\applications\xmlpserver\xmlpserver\WEB-INF)

      <?xml version="1.0" encoding="UTF-8"?>

      <xmlpConfig xmlns="http://xmlns.oracle.com/oxp/xmlp">

      <resource>

      <file path="C:\OracleBI\xmlp\XMLP"/>

      </resource>

      </xmlpConfig>

      1. Go to the BI Publisher Repository folder
        e.g. C:\OracleBI\xmlp\XMLP
      2. Copy all the folders except ‘DemoFiles’ under the above folder. (If you want to migrate a set of demo XML data files you can copy the ‘DemoFiles’ folder as well.
      3. Save the folders onto your local machine or check them into your source control system

      1.2 Locate BI Publisher Repository Content to a Target Instance

      1. Login to the target instance machine
      2. Go to the BI Publisher Repository directory.
      3. Copy the source repository folders, which are the ones you have copied at the above steps, to this folder.

      clip_image004

      1.3 Validate the Repository Migration

      1. Restart your target J2EE server, such as Oracle OC4J server.
      2. Login to the Target BI Publisher Enterprise Server

      clip_image006

      Once you have logged in, you should see all the directories and reports migrated from the source instance under Reports tab in the new target BI Publisher Enterprise Server.

      clip_image010

      Post-Migration Task at Target Instance

      After the BI Publisher Repository has been migrated successfully you want to perform a post-migration task to review a target specific information. Often that the development application instance doesn’t share the same information such as data source, delivery system, scheduling information, etc with the target instance.

      For example, when you have a project where you develop financial reports out of a financial database, usually you would have one financial database for development, one for Testing, and one for Production. And you would expect that each of the BI Publisher Enterprise Server instance would talk to each financial database but not share the same database among multiple BI Publisher servers. This is just an example for a data source but it can be applied to other settings such as follows.

      • Data Source
      • Security
      • Scheduler
      • Delivery

      When you have completed the migration process all the above settings are just the copies from the source system so you want to review the settings and update them appropriately so that they can be specific to a target system.

      When you do this review and need to update any of the information, it is strongly recommended that you do it through the BI Publisher Enterprise Server Admin UI, not through the manual file modification. Just to make sure you don’t accidentally broken the system.

      Thursday, February 18, 2010

      Drill Down to Detail or Another Report

      Six_degrees_of_separation

      I want to click some values in the report and see the detail report for the particular data. For example, when I see a Sales report and realize some regions sale revenue is way small and now I want to find something more detail to answer why, by opening up another report that has detail data for the particular regions.

      Well, this is sometimes called as ‘Drill Down’, sometimes ‘Report Link’, or ‘Reports Navigation’. Whatever the name is, what you want is so called ‘Master-Detail’ reports relationship with which a master report opens a detail report and passes a value to filter the data in the detail report.

      You can develop such reports very easily with BI Publisher. All you need to do is to develop two reports, one regular report with a hyper link and one with a parameter which will filter the data.

      As I covered yesterday you can receive the parameter value and use it within the RTF template to filter the data. But I’m going to pass the parameter value from the first report to a SQL query for the second report and have the SQL query (Database) to filter the data for the second report.

      So here are the steps we need to follow.

      Create Detail Report with Parameter

      Since we need to know the target report name and parameter value in order to create the hyperlink in the master report, let’s start with the detail report.

      First you create a report as normal, nothing special. And you add a parameter. Let’s just call it as ‘p_country’.

      parameter

      And put that parameter into a query for the report.

      query

      My example is using a LOV (List of Values) to get the ‘p_country’ parameter value list. And the report looks like the below.

      country_param

      Now you can select a value from the country parameter drop down list and the report data will be updated based on your selection.

      Create Report with Hyperlink

      Now the master report. Again, nothing special, you just create a report as normal. Only additional thing is to add a hyperlink. In order to do this you need to know the two things.

      • Target (Detail) Report Path
      • Target (Detail) Report Parameter

      For that, we need to go back to the detail report. And select ‘Current Page’ from ‘Link to this report’ menu at the right hand side top.

      link_to_this_page

      Copy the link into a notepad or something. Mine is something like below.


      http://knishida-lap.us.oracle.com:9704/bip/Data/Trend
      by Country/Trend by Country.xdo?_xpf=&_xpt=0&_xdo=%2FData%2FTrend%20by%20Country%2FTrend%20by%20Country.xdo&p_country=USA&_xt=Trend%20Chart&_xf=html&_xmode=0

      You can find the detail of the each parameter in the above link in BI Publisher’s Designer’s guide. But for now what we need to know at least is the report path and the report parameter. And those are ‘Report Path’ and ‘Report Parameter’. You can find those as below from the above link.

      Report Path http://knishida-lap.us.oracle.com:9704/bip/Data/Trend by Country/Trend by Country.xdo
      Report Parameter p_country

      Now you go back to the first report, open the RTF template and add the hyperlink on the place you want your users to click on. 

      table

      And use the MS Word’s menu to insert a link.

      link

      And you want to copy the URL link that you copied above. But before dump it into the hyper link box, you want to modify the link a little bit.

      There is a ‘p_country’ parameter in the link. Instead of hard coding its value you want to dynamically generate the the value by taking an actual value from the data when the report is generated. It’s basically the same thing as you do when you print or use the data in the RTF template, like <?ISO?>. Only the difference is you need to use these brackets ‘{‘, ‘}’ in stead of the BI Publisher’s tag ‘<??>’. With my report I can get the value as ‘ISO’ from the xml data, so it would be something like below.


      http://knishida-lap.us.oracle.com:9704/bip/Data/Trend by Country/Trend by Country.xdo?_xpf=&_xpt=0&_xdo=%2FData%2FTrend%20by%20Country%2FTrend%20by%20Country.xdo&p_country={ISO}&_xt=Trend%20Chart&_xf=html&_xmode=0

      Now one more thing. You never know what would be the host name when the report will be deployed, right? You might have different server instances like ‘Development’, ‘Testing’, ‘Production’, etc. There is a pre-defined BI Publisher’s variable called ‘CURRENT_SERVER_URL’, which returns an URL that contains hostname, port number, and the root path. So it would be ‘http://knishida-lap.us.oracle.com:9704/bip/’ for the above example.

      So now you can replace the URL to be something like:


      {$CURRENT_SERVER_URL}Data/Trend by Country/Trend by Country.xdo?_xpf=&_xpt=0&_xdo=%2FData%2FTrend%20by%20Country%2FTrend%20by%20Country.xdo&p_country={ISO}&_xt=Trend%20Chart&_xf=html&_xmode=0

      And now you can copy this and paste it into the hyper link box.

      link

      And here is one thing. In order to use the ‘CURRENT_SERVER_URL’ variable you need to declare it in the RTF template. SO you need to just type the following syntax at the beginning.


      <?param@begin:CURRENT_SERVER_URL?>

      And that’s all you need to do. Once you upload the RTF template you should be able to see the hyper link in the report. And the link should contain the report path and report parameter value, both of which are dynamically generated.

      report

      As you see in the above picture, each link has the ‘CURRENT_SERVER_URL’ and ‘ISO’ values dynamically generated. With my example, when I click the link for Japan it will open another report and show me the detail data about Japan.

      detail_report2

      Or,

      detail_report 

      So that’s pretty much it, though one last thing I should add. If you have tried this you must have already noticed. When you click the link it will open a new window. But you might want to keep in the same window to display the detail data. You can do this by un-checking ‘Open Links in New Window’ property.

      property

      Enjoy Drill Down/linking !

      Wednesday, February 17, 2010

      How to Pass User Input Values to Report Layout?

      “I want to allow my users to enter their comment from the report UI and print it in the report along with the reporting data.”

      “I want to change the calculation or condition logic based on the user’s selection or inputs at the runtime.”

      These are the questions I hear once in a while and the short answer is ‘Yes’. For example, you can do something like below, which users type their comment and generate the report with the comment.

      comment

      BI Publisher supports Parameter functionality, which allows the end users to select or enter values when they open the reports and filter the reporting data based on the input values.

      As a report developer you can pass this value to the underlying data source such as SQL query and filter the data result. For example, in order for you to pass this user input values and filter the data you can create a parameter called ‘param1’ and add the parameter value prefixing with ‘:’ into a WHERE clause. (e.g. where department_id = :param1)

      Now, how about passing the user input values to the layout template instead of to the SQL query ? Yes, you can pass the values to your template and use the values in your condition, calculation, or just to display it in the report output.

      It’s pretty simple, but there are a couple of steps to follow.

      Create Parameter at BI Publisher Server UI

      This is no brainer. You can just go to the Report edit window and create a report parameter from the UI.

      parameter

      Please see the Reports Designer’s guide for the detail.

      Declare Parameter in RTF Template

      Before you use the parameter in the RTF template file you need to declare it first. You can do so by having the following syntax.

      <?param@begin:%parameter_name%?> 

      Note: where %parameter_name% is the parameter name that you have created at the BI Publisher Server UI.

      Here is an example:

      <?param@begin:param1?>

      Use it in RTF Template!

      Once it’s declared in the RTF template you can start using it as the same way you use the variable. You need to just add ‘$’ prefix in front of the parameter name. Here is the example:

      <?$param1?>

      The above example would print the parameter value in the report output. If you want to use this value in your condition or calculation you can simply use it as ‘$param1’. Yes, it’s that simple.

      If you are not sure if and how the parameter values are passed to the report when you run the report you can use this command in your RTF template, which will return all the parameter values passed to the RTF template at the runtime.

      <?xdoxslt:getXDOProperties($_XDOCTX)?>

      Note that the above command has been introduced relatively new so if you’re running on an older version of BI Publisher it might not work.

      Anyway, so now you know the steps involved to get the user input values and use it within your RTF template. Have fun!

      Monday, February 8, 2010

      I Want My Custom Java Function for Siebel!

      Have you ever wanted to create a new customized function and call that from your RTF templates so that you don’t have to implement a same condition or calculation logic again and again with many different reports ?

      I talked about this yesterday a little bit, but I had this problem when I was developing the Siebel reports and had to implement a date formatting or do some date related calculations. As I discussed yesterday that the Siebel  Integration Object generates the date data in its own format like ‘08/15/2008 09:20:11’ unlike the ‘Canonical’ format that BI Publisher expects, which is something like ‘2008-08-15T09:20:11’. Please check the previous post for the detail.

      At the previous post, I have suggested two options to workaround this and talked about the first option with ‘totext()’ function. Today, I’m going to talk about the second option, which is to develop a Java custom function and use it in the RTF template.

      Develop Custom Extended Java Function

      BI Publisher supports the Java custom function that the users can develop their own functions with Java and call it from the RTF template. This will allow the users to hide tedious or complex calculation/business logic and centralize them in a single place, which not only improves the development productivity but also reduce the maintenance headache.

      So, how to develop the Java custom function ? Luckily, Mr. BIP, Tim Dexter, has already talked about how to develop the custom Java function at his blog. Please check his post for the detail. At this post I’m going to talk about how to create one to convert the Siebel’s date data to BI Publisher’s ‘Canonical’ date format.

      Here is the example of the function does the conversion.

      package oracle.bip.extensions;

      public class BIPExtensions {
          public BIPExtensions() {
          }
        
          public static final String convertDate(String cdate){
              String conv_date = "";

              if(cdate.length() == 11){
                  conv_date = cdate.substring(6,10)+"-"+cdate.substring(0,2)+"-"+cdate.substring(3,5);
              }else if(cdate.length() == 19){
                  conv_date = cdate.substring(6,10)+"-"+cdate.substring(0,2)+"-"+cdate.substring(3,5)+"T"+cdate.substring(11,19);
              }else{
                  conv_date = cdate;
              }
              return(conv_date);
          }

      }

      The example above is a pretty simple one for a demo. It gets the Siebel given date, convert it to the ‘Canonical’ date formatted string, and returns. If the given date contains only the ‘MM/DD/YYYY’ portion then it returns only the date in ‘YYYY-MM-DD’ format. If it contains the time data also then it returns ‘YYY-MM-DDTHH:MI:SS’.

      This is just an example. So of course you can develop anything you want and develop as many functions as you want in the same class. Once you completed the development you can compile it and deploy it to a JAR file.

      At this point, the next thing you want to do is to test the function with your RTF template. There are three steps to follow.

      Setup Your MS-Word Add-in Template Builder Environment

      I have talked about how to setup the MS-Word Template Builder environment so that we can use the Siebel’s extended functions at this post, ‘Siebel’s Extended Function for RTF Template’.

      Basically we need to do the same thing in order to use the above custom function. So what we need to do is to add one more JAR file location in the ‘_JAVA_OPTIONS’ variable in the MS-Word launch batch script file. Here is the example assuming that the JAR file is called ‘BIP_Extension.jar’ and located under ‘C:\JDeveloper\mywork\Local\Project1\deploy\’.

      echo %1

      set _JAVA_OPTIONS=-Xbootclasspath/a:D:\811DQSSIA\client\classes\SiebelXMLP.jar;D:\811DQSSIA\client\classes\XMLP.jar;D:\811DQSSIA\client\classes\siebel.jar;D:\811DQSSIA\client\classes\XSLFunctions.jar;D:\811DQSSIA\client\classes\SiebelCustomXMLP.jar;D:\811DQSSIA\client\classes\SiebelCustomXMLP_SIA.jar;C:\JDeveloper\mywork\Local\Project1\deploy\BIP_Extension.jar

      "C:\Program Files\microsoft office\Office12\Winword.exe" %1

      Now you can double click this .bat file to open your RTF template.

      Declare a Name Space for the Extended Function

      As mentioned in the ‘Siebel’s Extended Function for RTF Template’ post, you need to first specifying the custom class file by declaring its name space with the class path.


      <?namespace:bipext=http://www.oracle.com/XSL/Transform/java/oracle.bip.extensions.BIPExtensions?>

      Use it!

      Once the name space is declared then you can use it as the same way you use the ‘xdoxslt’ or ‘xdofx’ functions. Type the name space first then type the function. Here is an example.


      <?bipext:convertDate(ssCreatedDate)?>

      My convertDate function takes an input parameter value of date string so I set a XML element name that holds the date data.

      And after you ensure that the functions works appropriately then you can deploy it to the server side following the steps at ‘Siebel’s Extended Function for RTF Template’.

      Conclusion

      So now you got this whole freedom of developing and adding your functions to the BI Publisher’s reports development realm. However, note that as I suggested before you should review the existing BI Publisher’s native functions and the Siebel’s extended functions first to see if they can be used to meet your requirements. Developing your own new functions means you will be responsible for the maintenance. And it’s not uncommon that one developer develops something and leave after a project is completed, then the other members left alone have no idea how to fix it when a problem occurred with the custom functions. As long as you use the functions provided by Oracle then Oracle will be responsible for the fix. That’s the difference you want to consider for the long term.

      Keep that in your mind have fun with the custom Java function !

      Friday, January 29, 2010

      My Date doesn’t like me with Siebel !

       bizarro-play-date

      Are you doing ok with your date in the Siebel reporting with BI Publisher ?

      If you are coming from Siebel this might make you kind of confused because the BI Publisher user’s guide tells you it supports all sorts of the date formatting and date related calculations but somehow it doesn’t work when you try with the Siebel reports. If you are coming from BI Publisher reporting world you might have figured out why it doesn’t.

      BI Publisher provides quite various of ways of the date formatting and date related calculations. You can find the detail from the BI Publisher’s Reports Designer’s Guide. Here is a section for the date formatting. And here is a section where you can find the date related functions that you can use to do the date related calculation.

      However, in order for BI Publisher to do the date formatting or the calculation the date data (in the XML data) needs to be presented as something called ‘Canonical’  format, which is something like ‘2008-10-09T05:31:13.000-04:00’. The example contains Year, Month, Day, Time, and Time zone difference from GMT. It doesn’t need to contain the time and the time zone difference parts, but it needs to have the date part at least. And it needs to be in ‘YYYY-MM-DD’ or ‘YYYY-MM-DDTHH:MI:SS’ format.

      And now, the date data generated by Siebel with the IO is in ‘MM/DD/YYYY HH:MI:SS’ format, so it is something like ‘10/09/2008 05:31:13’. And BI Publisher doesn’t recognize that this is a date data because it’s not presented in the ‘Canonical’ format!

      Due to this fact, not only you can’t do the date formatting but also you can’t do the date related calculation. For example, you might want to print number of day between two presented dates like start date and end date. If the those two date data is presented in the ‘Canonical’ format then you can use something like ‘date_diff()’ function to get the duration counted between the two dates. But it doesn’t do anything or you get an error if you provide those two dates not in the ‘Canonical’ format.

      There is a discussion in the Siebel reporting product development that this might be addressed in the next Siebel FixPack by having IO returning the date in the ‘Canonical’ format. But it’s not determined yet and guaranteed.

      So what should we do now ? There are two possible and reasonable workarounds to overcome this issue. The first one is to use one of the Siebel’s extended function ‘totext()’ to convert the Siebel date format to the ‘Canonical’ date format before the BI Publisher’s date related function comes in. Here is an example of how to use to convert the date.


      psfn:totext(ssCreated,"yyyy-MM-dd","MM/dd/yyyy")

      The above example is giving the Siebel date data, telling what date format the presented date data in, and telling how to convert. So if the ‘ssCreated’ is ‘10/09/2008’ then it would return as ‘2008-10-09’, which is the ‘Canonical' date format. Once you get your date data in the ‘Canonical’ format then you can do the date formatting or use the date functions to meet your requirements.

      The advantage of this option is easy and quick to implement and you don’t need any customization. The disadvantage of this option is that as you see it gets messy especially when you want to do a date related calculation in a complex business logic because you need to specify the date formats every time you use it.

      The second is to develop a custom Java function to convert the date from, the Siebel’s date format to the ‘Canonical’ date format. As you might know BI Publisher supports a way for you to develop custom functions with Java and use them in the RTF template. The advantage of this option is clean and easy to use. The disadvantage is that you need to develop the Java code and deploy it to the server, which might require the system administrator’s help if you don’t have an access to the server instance.

      So now, at least you can get your date data work in the Siebel reports! And I will discuss on how to develop the custom Java function for Siebel reports tomorrow. So again, stay tuned!

      Wednesday, January 27, 2010

      What to Do with these Siebel Extended Functions?

      After you run the Actuate to BI Publisher conversion utility and open the generated RTF template file you would find something like below in the text forms, though it depends what you had in your old Actuate report.

      <?value-of:concat(concat(ssActiveFirstName," "),ssActiveLastName)?>

      <?value-of:psfn:Format(psfn:CInt(TotalCommit1),"$#,##0")?>

      <?value-of:concat("Printed on: ",psfn:Format(psfn:currentdate(),"mm/dd/yyyy"))?>

      And when you try to preview with your MS-Word with BI Publisher Add-in, you’ll get an error.

      First of all, when you try to preview the report after loading a sample XML data by using the MS-Word add-in (Template Builder) you need to follow some steps that I discussed yesterday.

      Second, the ‘value-of’ just doesn’t work. I don’t even know why they are there. But the good news is you can just get rid of them!

      And now, assuming that your MS-Word Add-in has already been setup correctly and you have declared the ‘psfn’ name space in your RTF template, the next step is to figure out ‘what the hell are these functions doing?’

      The conversion utility generated those codes with the Siebel’s extended functions doesn’t mean that you need to use them as they are. Most of the functions are covered and can be replaced by the BI Publisher’s existing functions so no need to use the Siebel’s. I would recommend to use the BI Publisher’s ones over the Siebel’s ones due to a long term maintenance advantage. However, some of the functions are not provided by BI Publisher, then you want to stick with the Siebel’s extended functions like the ones I recommended yesterday.

      So What to Do with These Syntax?

      Well, this really depends on each case but here is a list of the steps that you can take to reach to the answer.

      1. Understand what it’s trying to do
      2. See if there is any BI Publisher’s native function that can be used to provide the same functionality
      3. If yes to the #2 question then replace and test
      4. If no to the #2 question then see if it works without any modification
      5. If no to the #4 question then come up with a logic by using BI Publisher’s native function or developing a new custom Java function

      1. Understand What It’s Trying to Do

      You can guess what it’s trying to do just by looking at the generated code. But it’s always better to see the original logic in the Actuate report definition. And it’s even better to review the original business requirement. Often that the requirement has been changed over the years and some of the logic might not be relevant anymore. If that’s the case you definitely don’t want to spend any of your time on something that is not meeting today’s requirements.

      2. See if there is any BI Publisher’s Native Function

      Once you understand the requirement and what the syntax is trying to do then review the BI Publisher’s function list to see if any of the functions can replace it without compromising the requirement.

      3. Replace It and Test It

      No much to talk about here, but go ahead replacing it and make sure the result is meeting the expectation.

      4. Leave It As It Is and Test It

      If you can’t find any BI Publisher’s function that can replace it then try to use it and see if it works. If it works then great, but I had some functions that didn’t work (e.g. CnvDate), and later I was told that they were not even supported! So it’s important to setup your MS-Word and test it on your local environment before uploading it to the Siebel server.

      5. Come up with a New Way

      If you can’t find any BI Publisher’s function that can replace and the Siebel’s extended function doesn’t work then you need to come up with a way to make it work to meet the requirements. With BI Publisher’s flexible development framework usually you should be able to find a way easily to achieve this by combining the existing functions or XSL/XPath functions and creating a logic.

      As a long term solution though, if you see this function or logic can be used in many other reports, then you might want to think about developing your own Java custom function. BI Publisher supports such custom function being developed by Java and being used in the RTF template. I will cover this later this week.

      Now let’s see what we can do with those in the above example.

      What Can We Do With the Examples

      Example 1:

      Here is the first one.


      <?value-of:concat(concat(ssActiveFirstName," "),ssActiveLastName)?>

      This one is simply trying to print First Name and Last Name in this order and have one space between so the result would be something like below.

      Barak Obama

      As most of you know this is where it becomes so easy to develop and design with BI Publisher. What you need to do is just this.


      <?ssActiveFirstName?> <?ssActiveLastName?>

      You can either use the two text forms (the gray square box ones) or just type the above, and adjust the space between in the MS-Word.

      Example 2:

      Here is the second one.


      <?value-of:psfn:Format(psfn:CInt(TotalCommit),"$#,##0")?>

      This one is trying to do the number formatting in this ‘$9,990’ format. And CInt is trying to ensure that the data is always passed as number. You can simply replace this by get rid of all but the ‘TotalCommit’ data element like below.


      <?TotalCommit?>

      Then use the BI Publisher’s property UI where you can specify your desired number format.

      Example 3

      And here is the last one.


      <?value-of:concat("Printed on: ",psfn:Format(psfn:currentdate(),"mm/dd/yyyy"))?>

      This is trying to print the current date as a ‘Printed’ date so that the users know when this report is generated. There are actually many ways to print the ‘Current date’ with BI Publisher. And here are some examples.

      <?xdofx:sysdate()?>

      <?xdoxslt:current_date($_XDOLOCALE, $_XDOTIMEZONE)?>

      <?xdoxslt:sysdate_as_xsdformat()?>

      The date formatting itself is a whole another topic and I leave the detail to another post later. But you can use one of the above to return the current date and use the BI Publisher’s property UI, the one pop up when you double click the gray box, and specify your desired date format. And again, you don’t need the ‘concat’ function to concatenate the two strings. You can simply type the ‘Pritned on: ‘ and have the text form box next which includes one of the above syntax.

      Conclusion

      The chances are you will have more and various different requirements and can have the RTF templates generated with more various and can be funky syntax. Hope this post help you to get started and give you a starting point and make your reports development more enjoyable.