Quantcast
Viewing all articles
Browse latest Browse all 676

Insert data into SAP HANA from BO WEBI report through XS application

Hello All,

 

In this blog, I have explained about how to insert records into SAP HANA from a reporting tool like Web Intelligence. This concept can be used in most reporting tools like Dashboards, Lumira & Design Studio to insert data into SAP HANA.

 

Please find below steps to acheive this.

 

 

1. Create table in sap HANA

 

Create column table with name T_B_SALES with below structure in SAP HANA.

Image may be NSFW.
Clik here to view.
pic1.png

 

 

2. Create SAP HANA Repository

 

 

Goto Window -> Show View from Top Menu Bar

 

Select SAP HANA Repositories.

 

Image may be NSFW.
Clik here to view.
pic2.png

 

 

 

Right click on the Repository Area & create new repository.

 

Image may be NSFW.
Clik here to view.
pic3.png

 

 

Give Repository Name and click finish.

 

Image may be NSFW.
Clik here to view.
pic4.png

 

You will see the Repository successfully created in SAP HANA.

Image may be NSFW.
Clik here to view.
pic5.png

 

 

  3. reate XS Application

 

Go to Window -> Show View from Top Menu Bar and select Project Explorer.

Image may be NSFW.
Clik here to view.
pic6.png

 

 

4. In Project Explorer Create New XS Project

 

 

Right click in Project Explorer Area New-> Project ->SAP HANA Development->XS Project.

Image may be NSFW.
Clik here to view.
pic7.png

 

Give Project Name & Click on Finish. Now you will see a XS Project folder created in Project Explorer.

Image may be NSFW.
Clik here to view.
pic8.png

 

5. Create .xsapp & .xsaccess files in XS Project

 

Right Click on XS Project folder and select ‘file’ option.

Image may be NSFW.
Clik here to view.
pic9.png

 

 

  Give file name as .xsapp. Keep this file blank. This file is for XS engine to understand there is an XS application in this package.

Image may be NSFW.
Clik here to view.
pic10.png

 

Similarly create .xsaccess file & write below code in it.

Image may be NSFW.
Clik here to view.
pic11.png

 

 

 

Right Click on our XS Project XS_BOOK_STORE and create XS JavaScript Source File.

 

Image may be NSFW.
Clik here to view.
pic12.png

 

 

 

Name it as “insert_purchase_record.xsjs” and write below code in it.

  var cid = $.request.parameters.get('cid');

  var bname = $.request.parameters.get('bname');

var no_of_copies = $.request.parameters.get('no_of_copies');   
$.response.headers.set(
'access-control-allow-origin','*');

  varconn = $.db.getConnection();

   var pstmt = conn.prepareStatement("INSERT INTO \"UNAME\".\"T_B_SALES\"
values ('"
+cid+"','"+bname+"',current_date,"+no_of_copies+")");

var rs = pstmt.execute();

   $.response.setBody( "Entry has been created Successfully.");

  }

 

  conn.commit(); 

  conn.close();

 

Note: UNAME is username in SAP HANA

 

 

Share Project

Right Click On Project and goto Team-> Share Project

Once your Project is shared small Yellow cylinder will appear at Project Logo.

Image may be NSFW.
Clik here to view.
pic12_1.png

 

 

Now Select all the 3 files (.xsapp,.xsaccess and insert_purchase_record.xsjs) and Activate the files.

Image may be NSFW.
Clik here to view.
pic15.png

 

 

 

Then all files will show the small Yellow cylinder at file logo after successful activation of files.

Image may be NSFW.
Clik here to view.
pic14.png

 

 

6. Create a WEBI report which will write data back to SAP HANA.

Create WEBI report with No data Source. As we do not want to see any data, and need to insert data into HANA DB.

 

Create 3 Variables in BO as below

Image may be NSFW.
Clik here to view.
pic15.png

 

 

 

Define 3 input control Text Boxes for each of variables.

Image may be NSFW.
Clik here to view.
pic16.png

Image may be NSFW.
Clik here to view.
pic17.png

 

 

 

Create Report with above variables as below. Try to articulate it to appeal to users.

Image may be NSFW.
Clik here to view.
pic18.png

 

 

 

Do not forget to select cell property of insert cell to Hyperlink, as below.

Image may be NSFW.
Clik here to view.
pic19.png

 

 

Now, right click On the “Insert” Text, Goto Linking->Hyperlink and put below code in window & parse it.

 

http://<HANA_SERVER>:<PORT>/XS_BOOK_STORE/insert_purchase_record.xsjs?cid=B0000001&bname=INDIA&no_of_copies=1 

 

  PORT: Mostly = 8000 (for HANA XS ENGINE)

Image may be NSFW.
Clik here to view.
pic20.png

 

 

Click on parse. Below window will now appear,

 

Image may be NSFW.
Clik here to view.
pic21.png

 

 

Now assign the BOBJ variables to URL parameters, as below.

 

Image may be NSFW.
Clik here to view.
pic22.png

 

 

7. Execute the BO Report

 

Now let’s test our XS application..!

 

Click on insert, this will take you to the browser and will prompt you to enter HANA password.

Image may be NSFW.
Clik here to view.
pic23.png

 

  After entering the password and clicking OK it you show you following window.

Image may be NSFW.
Clik here to view.
pic24.png

 

 

 

Now Check HANA table T_B_SALES. You will see one entry created in table..!!

 

Image may be NSFW.
Clik here to view.
pic25.png

 

 

You can now also try to update and delete the records in HANA DB. You can use the same table, on which we are performing DML operations, as the BOBJ report source and can see the records gets change at WEBI Report level at runtime.

 

Hope you find this worth of reading..!! Thanks


Viewing all articles
Browse latest Browse all 676

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>