Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member197386
Active Contributor

In this post, you will find out how to schedule a Web Intelligence document having a parameter, using Raylight (the RESTful webservices API for Web Intelligence).

The two main parts of this workflow are:

- discovering if parameters are needed

- scheduling the document with parameter answers

As prerequisites, you should be able to understand the basic concepts of a RESTful Web Services and ideally you have already used Raylight. No programming skill is needed.

Preparing the document with a prompt

To get started with this tutorial, you need to add a mandatory prompt to the well-known standard WebI document sample, named "Formatting Sample" which can be found in the "Web Intelligence Samples" in the BI Launch Pad.

- Open the document "Formatting Sample".

- Click "Modify" button to edit the document.

- Choose "Data Access" > "Data Providers" > "Edit" to pop up the Query Panel

Only one query is present in this sample, quite simple :smile:

- Add a prompt on "Year" (the prompt is a mandatory by default)

- Click "Run Query".

- Enter "2004" as prompt answer

- Save the document

Prepare Azot script

Raylight is the RESTful API which allows you to use Web Intelligence features from anywhere using any kind of technologies. To practice this tutorial, we will use Azot, an Open Source tool that performs REST workflows with simple XML scripts.

The latest version of Azot can be freely downloaded from here.

You will find a script named "schedule-with-parameter-sample.xml" attached to this blog post.

Modify it with the RESTful server name, login, and password to set up your BI4 landscape.

Then execute the script:


C:\raylight-stuff>java -jar azot.jar schedule-with-parameter-sample.xml

Step 1 - Discover if parameters are needed

To know if the document contains parameters (often called "prompt"), we perform a [GET] /documents/{docID}/parameters.

To do this, uncomment the 4th call in the Azot workflow.


<!-- (4) Get document parameters -->
<call name="GetDocumentParameters">
  <request url="${raylightUrl}/documents/${docID}/parameters" method="GET">
       <header name="Accept" value="application/xml" />
       <header name="X-SAP-LogonToken" value="${token}" />
  </request>
</call>






Execute the script again and see that parameters are now printed out.

Note: sometimes, it may exist "cascaded parameters", especially when the there is a context in the document. In this case, we have to perform several calls to be sure we capture all requested parameters. This workflow could be the object of another blog post if some people are interested in.


Step 2 - Schedule with parameters

Now, to schedule with parameters, we just have to send a POST request by providing the desired answer for the parameter.

Uncomment the 5th call in the Azot workflow: the parameter structure is send back with the answer.



<!-- (5) Schedule document with parameters -->
<call name="UpdateTheDocumentWithParameters">
  <request url="${raylightUrl}/documents/${docID}/schedules" method="POST">
  <header name="Accept" value="application/xml" />
  <header name="X-SAP-LogonToken" value="${token}" />
  <header name="Content-Type" value="application/xml" />
  <content>
            <![CDATA[
  <schedule>
  <name>My First Scheduling with Parameters</name>
  <format type="webi" />
  <destination><inbox/></destination>
  <parameters>
  <parameter dpId="DP1" type="prompt" optional="false">
  <id>0</id>
  <technicalName>Enter value(s) for Year</technicalName>
  <answer>
  <values>
  <value>2005</value>
  </values>
  </answer>
  </parameter>
  </parameters>
  </schedule>
              ]]>
  </content>
  </request>
</call>






The response for this request will be :


<success>
    <message>The resource of type "Schedule" with identifier "18006" has been successfully created.</message>
    <id>18006</id>
</success>






Step 3 - Verify that everything is OK

Check that everything is OK in the "History" of the WebI document we scheduled previously, in the BI Launch Pad.


Open the scheduled instance to verify data in the report.

You can also check the status using a simple [GET] call:

[GET] /documents/5111/schedules/18006

Note: 18006 is the schedule identifier sent back after schedule creation

2 Comments