Skip to Content
Author's profile photo Former Member

Copying variables from a WEBI document to another document

UPDATE : For those who just need a way to copy variables from one document to another, take a look at the update at the end of this document.


I would like to share a small script to include variables from one WEBI document to another. I´m using Javascript and the code is a HTML document.

I think it will be usefull because you can build a document with some variables and then reuse it , with minimum effort, in another document.

It works on SAP BO BO 4.1 SP3 on


1 – There is a WEBI doc that holds the definition of the variables which ID is  DocIdFrom;

2 – You want to include the variables to a WEBI doc which ID is DocIdTo

3 – You have just one query in DocIdTo  (Query 1)

4 – The variables to be inserted are only those which has objects that has corresponding objects in Query 1

5 – Variables that depends on another variable will not be inserted at first, run the script again to insert them


1 – Logs into the platform

2 – Gets the list of variables from DocIdFrom

3 – Loops through the list to get its definition

4 – insert the variables into DocIdTo

5 – Logs off the platform

There goes the script :







// Logs into the platform

var logon = new XMLHttpRequest();

    var url = ‘http://<server>:6405/biprws/logon/long’;

    var action = ‘logon/long’;

    var body = ‘<?xml version=”1.0″?><attrs xmlns=”“><attr name=”userName” type=”string”>USERID</attr><attr name=”password” type=”string”>PASSWORD</attr><attr name=”auth” type=”string” possibilities=”secEnterprise,secLDAP,secWinAD”>secEnterprise</attr></attrs>’;

    var response;

    var logonToken;‘POST’, url, false);

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

    logon.setRequestHeader(‘Content-Type’, ‘application/xml’);

    logon.setRequestHeader(‘Accept’, ‘application/xml’);


   logonToken = logon.getResponseHeader(‘X-SAP-LogonToken’);


   logonToken= logonToken.substring(1,logonToken.length-1);


// gets the list of variables

    var getListVar = new XMLHttpRequest();

    var url = ‘http://<server>:6405/biprws/raylight/v1/documents/’+DocIdFrom+’/variables’;‘GET’, url, false);

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

    getListVar.setRequestHeader(‘Content-Type’, ‘application/xml’);

    getListVar.setRequestHeader(‘Accept’, ‘application/xml’);

    getListVar.setRequestHeader(‘X-SAP-LogonToken’, token);


    var def=getListVar.responseText;

    var nodesVar = getListVar.responseXML.getElementsByTagName(“id”);


    // loops through the variable list

    for (i=0;i<nodesVar.length;++i)



    // gets the variable original definition

        idVar = nodesVar[i].innerHTML;

        var getSpecVar = new XMLHttpRequest();

        var url = ‘http://<server>:6405/biprws/raylight/v1/documents/’+DocIdFrom+’/variables/’+idVar;‘GET’, url, false);

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

        getSpecVar.setRequestHeader(‘Content-Type’, ‘application/xml’);

        getSpecVar.setRequestHeader(‘Accept’, ‘application/xml’);

        getSpecVar.setRequestHeader(‘X-SAP-LogonToken’, token);



// inserts the variable

        var setSpecVar = new XMLHttpRequest();

        var url = ‘http://<server>:6405/biprws/raylight/v1/documents/’+DocIdTo+’/variables’;‘POST’, url, false);

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

        setSpecVar.setRequestHeader(‘Content-Type’, ‘application/xml’);

        setSpecVar.setRequestHeader(‘Accept’, ‘application/xml’);

        setSpecVar.setRequestHeader(‘X-SAP-LogonToken’, token);



// saves the document

var saveDoc = new XMLHttpRequest();

    var url = ‘http://<server>:6405/biprws/raylight/v1/documents/’+DocIdTo;‘PUT’, url, false);

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

    saveDoc.setRequestHeader(‘Content-Type’, ‘application/xml’);

    saveDoc.setRequestHeader(‘Accept’, ‘application/xml’);

    saveDoc.setRequestHeader(‘X-SAP-LogonToken’, token);


   // logs off

var logoff = new XMLHttpRequest();

    var url = ‘http://<server>:6405/biprws/logoff’;‘POST’, url, false);

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

    logoff.setRequestHeader(‘Content-Type’, ‘application/xml’);

    logoff.setRequestHeader(‘Accept’, ‘application/xml’);

    logoff.setRequestHeader(‘X-SAP-LogonToken’, token);









UPDATE 05/26/2015

There´s a much easier way of copying variables from one document to another.

Since BO 4.1 SP3, you can copy blocks from one (DOC A)  document to another (DOC B) in WEBI Rich Client. In order to do so, right click the block you want to and choose copy, go to the other document right click and Paste. (it will take a while to the process to end (sometimes it can take some minutes).

When you copy the block, the associated quey(ies)  (the one(s) that brings the respective data from the block will be copied as well.

If you need to copy some variables from DOC A to DOC B, just create a dummy block with these variables in DOC A and then Copy and Paste the block into DOC B

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hello Rogerio,

      Today I tried to run the above script, but I didn’t get far 🙁

      I exchanged the <server>, USERID, PASSWORD; DocIdFrom; DocIdTo in the script with my own credentials, saved the file as "WEBI-REST-Script.html" on the desktop but nothing happens when I run it.


      Could you please advise me how to get it work?


      (I was able to obtain the Token via the RESTful Chrom-Client “Postman”, so in general the service on the BO-Server seems to work)

      Kind regards


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

      Hello Agata,

      So sorry about my very late reply.

      Can you do me a favor ? On google chrome, press F12 (this will open the debugger) on the top of the window, click at Console. Press CTRL+PrintScreen and paste it on word.

      Can you send me the file ?



      Author's profile photo Former Member
      Former Member

      Hello Rogerio,

      never mind, happy to hear from you 🙂

      Here ist the screen you requested, and thank you for your help.




      Author's profile photo Bulent Ozgul
      Bulent Ozgul

      Hi Rogerio,

      Another newbie 🙂

      I've just started yesterday for my first restful sdk and faced with my first error 🙂

      if i debug the code i get an error on the

      // gets the variable original definition

              idVar = nodesVar[i].innerHTML;

      line. if i checked the value for idvar it shows "undefined". i add a watch for "nodesvar" and i see the values for the i=0 node. but couldn't see a "innerhtml" method/object value.

      the code runs fine until this line. logon is successful, the "def" variable shows the variable of my "from" document.

      do you have any idea?

      By the way thanks a lot for your post. At least i can log on to my BI system via restful SDK and can do something. Your code was very helpful for me.

      Author's profile photo Bulent Ozgul
      Bulent Ozgul

      I change the code like this and now it's working:

      delete the line

      var def=getListVar.responseText;

      put these line

      var def=getSpecVar.responseText;

      after the line