Skip to Content
Author's profile photo Former Member

Inserting comments on a WEBI doc – Two extra approaches

   Hi Everyone,

I would like o share two extra approaches to make use of persistent comments into a WEBI doc. I´m saying two extra ways because this subject has already been  discussed by WILLIAM MARCY  inEnabling Comments in Web Intelligence Reports using Input Controls

The first approach works only in design mode, the second ,albeit working on reading mode, can be better explored in design mode.

1) First approach – Use of blank cells.

    This approach is based in the use of blank cells and consists , simply in dropping blank cells at the places where you want the comments to be in the report. One can simply double click on the cell to edit its content. And, if the person wants the comment to have multilines, just edit the content using the formula editor.

2) The second approach makes use of HTML5 and Javascript, and saves the comments to a Database to further access. In this particular example, I´m using MongoDB (www.mongodb.com) as a dataprovider and Mongolab (www.mongolab.com) as a DaaS provider. I´m not sure about it, but I think that you can use SAP Hana as the dataprovider (to be confirmed), anyway, any Database that has a Javascript driver will do.

The reason why I choose MongoDB are two folded :

a- Flexibility – As a key-value NoSQL database, MongoDB can hold any kind of data in a very interesting way. You can literaly save a variable to Mongo without any e3ffort

b – Ease of use – Mongolab has a Rest API to perform Database operations, in this sample I´m using a Rest call to write to Mongo and a second one to write. Besides, mongolabs provids a free plan (the one used).

I used a query over e-fashion that returns [Lines]. My report consists on a vertical table with two columns :

– [Lines] and

– [comments] , a measure variable with the following formula :

        =”<div><textarea id='”+[Lines]+”‘></textarea></div>” and its “Read as” property to HTML.

For those unfamiliar with HTML, variable will generate, for each [Lines], a small textbox, where the user will enter its comments.

There are three blank cells that holds the HTML for the click buttons and some Javascript code to read and write from Mongolabs.

The script are :

1 – Save button  – <input type = “button” value=”Save Comments” onclick=”saveComments()”

2 – read button – <input type = “button” value=”Read Comments” onclick=”readComments()”

3 – Script to read and write from the database

<script>

// array to hold the documments retrieved from the Database

var arrCom =[];

// the structure of the documment to be saved

function Comment ()

{

  this.line=””;

  this.text=””;

}

// function to save the comments to Mongo

function saveComments() {

var txt=””


// comments will be an array with the textarea elements

var comments=document.getElementsByTagName(“textarea”);

// loops through the array , creating a new document, and adding it to the array filling its values, and pushing it to the array

for (i=0;i<comments.length;++i) {

   var   com = new Comment();

   com.line=comments[i].id;

   com.text=comments[i].value;

   arrCom[arrCom.length]=com

  }

var enq=””;

enq=JSON.stringify(arrCom);

//Rest call to save the comments to the Database

     var invocation = new XMLHttpRequest();

     var url = ‘https://api.mongolab.com/api/1/databases/bobj/collections/bobj?m=true&apiKey=IZzAl7-Sd8i9SZMJ25lpSSsT_45xNNdW

     invocation.open(‘PUT’, url, false);

   invocation.setRequestHeader(‘X-PINGARUNER’, ‘pingpong’);

   invocation.setRequestHeader(‘Content-Type’,’application/json’);

   invocation.setRequestHeader(‘Accept’,’application/JSON’);

   invocation.send(enq);

}

// function to read the comments from the database

function readComments() {

var arrComments= [];

var invocation = new XMLHttpRequest();


// Rest call to read the comments into arrComments, an array

var url = ‘https://api.mongolab.com/api/1/databases/bobj/collections/bobj?apiKey=IZzAl7-Sd8i9SZMJ25lpSSsT_45xNNdW

     invocation.open(‘GET’, url, false);

   invocation.setRequestHeader(‘X-PINGARUNER’, ‘pingpong’);

   invocation.setRequestHeader(‘Content-Type’,’application/json’);

   invocation.setRequestHeader(‘Accept’,’application/JSON’);

   invocation.send();

   arrComments= JSON.parse(invocation.responseText)


  // loops through the array and, for each element, finds its correpondent textarea assigning its value

   for (i=0;i<arrComments.length;++i) {

       document.getElementById(arrComments[i].line).value=arrComments[i].text;

  }

}

</script>

Notice that :

1 – This sample was elaborated as a proof of concept, swo is lacking a lot of funcionality;

2 – The Rest API, in the way is used in this sample, isn´t a good implementation

I´m attaching a wid file to the post with this example. It has a txt extension so it can be uploade. It´s on 4.1 SP6, To use it, first change its extension from txt to wid, open it with WEBI Rich Client and exports it to BI Launch PAD,

cokments will be highly appreciated

Regards,

Rogerio

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo William MARCY
      William MARCY

      Using "comments" is such a big deal in Webi, very good explanation to use this feature right now.

      However, don't care about that, SAP integrates "comment" in the future release SAP BI 4.2 maybe for Q1 2016. I've tested it, and it works fine. A new button is available in the first tab of design mode and you can insert a document (actually a blank cell).

      Then you can add a comment in Design mode and finally, in View mode, you can answer to an existing comment.

      At the installation wizard, you can choose the database that you want to store the comment database as the CMS database or audit database.

      So great news ! πŸ™‚

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks for your comment William!!!

      Regards,

      Rogerio

      Author's profile photo Zeenat Goyal
      Zeenat Goyal

      Hello Rogerio

      Above one is a wonderful explanation, I want to achieve the same functionality but I am using BO 4.1 SP5 over Microsoft SQL server 2012,

      Could you help me here, if this could be possible in my existing scenario

      Thanks ZG

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Zeenat, e-mail me, you can find the e-mail at my profile.

      Regards,

      Rogerio

      Author's profile photo Zeenat Goyal
      Zeenat Goyal

      Hello William,

      I have a similar requirement, my banking client wants to have a comments field in the report, and I am searching for similar requirement, I would appreciate , if you could provide me your email ID, where in I can drop you a note.

      And it would be kind enough if you reply me back on the same note in the email.

      Waiting for your response.

      Thanks ZGoyal

      Author's profile photo William MARCY
      William MARCY

      I think Rogerio will be a better help for you πŸ˜‰

      Sorry Rogerio Plank it's your turn ! πŸ™‚

      Author's profile photo Zeenat Goyal
      Zeenat Goyal

      Thanks William

      Author's profile photo Sateesh Kumar Bukkisham
      Sateesh Kumar Bukkisham

      Hi Rogerio ,

      Very useful information .Eventhough we get comments feature in 4.2 , we know most customers will not be going immediately . Definitely it helps lot of requirements .

      We have same requirement to do against SAP BW/ SQL server/Oracle . I couldn't find your email address in profile page .

      can you lease share your inputs at bosateesh@gmail.com.

      Thank you very much πŸ™‚