How to add variable using BO RE Java SDK

I got an interesting task – add variable VERSION specifying the service pack to about 50 webi documents. I had to invent something more clever then going through all them manually.

The following function can be used to add a dimension variable with name name and value value to webi document widoc.

public static boolean addReplaceVariable(DocumentInstance widoc,
                                              String name,
                                              String value)
   ReportDictionary dic = widoc.getDictionary();
   VariableExpression[] variables = dic.getVariables();
   boolean found = false;
   for (VariableExpression e : variables) {
      if (e.getName().equalsIgnoreCase(name)) {
         System.out.println("variable " + name
             + " expression " + e.getFormula().getValue()
             + " was replaced with " + value);
         found = true;
   if (!found) {
      try  {
         dic.createVariable(name, ObjectQualification.DIMENSION, value);
         System.out.println("variable " + name
                          + " with value " +  value
                          + " has been created");
      } catch (Exception e) {
         System.out.println("ERROR: the variable " + name + " cannot be created");
         return false;
   return true;

It can be executed

if (addReplaceVariable(widoc, "VERSION", "=\"\"")) {;

More information

Getting started with BO RE Java SDK

7 thoughts on “How to add variable using BO RE Java SDK

  1. RAGHU


    I have a similar requirement. I have nearly 500 reports, each report having logo on the right up corner in all tabs, in a cell having formula “boimg://logo.bmp” and read as image URL. Now i have come up with change in logo format. Now the same formula is to be changed to “boimg://logo.jpg”.

    Env:BOXI 3.1 SP3

    Please suggest me java code for the same.



  2. Subodh

    Hi Dmytro,

    Your posts have been very helpful for me. I really appreciate the effort which you put in to explain everything.

    I have a requirement where I have to allow the customer to create New Web intelligence Report with default Header layout and Footer layout with logo.

    Another requuirement is that the Customer should be able to change the table Column header color, fonts etc. in all webi reports which have been already created and saved by specifying the values at only 1 file location.

    Can this be done?



      1. Subodh

        Hi Dmytro,

        Thanks for responding so fast. Can you please give me a brief Idea of how to achieve the above requirement.I am using XI 3.1 .

        Thanks !!



Leave a Reply

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

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

Facebook photo

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

Connecting to %s