Technology Blog Posts 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: 
thomas_jung
Developer Advocate
Developer Advocate
28,750

With the recent release of SAP HANA SPS6 (Revision 60), developers working on SAP HANA can expect a wide variety of new and improved features.  In this blog I would like to highlight a few of the most prominent features for developers building SAP HANA native applications.

Development Workflow

First, we have various improvements to the overall development workflow; most of these improvements focused on the SAP HANA Studio. For example SAP HANA Studio in SPS6 brings in Eclipse 4.2, introduces new object search dialogs, better integration of the view modeling tools into the Repository view and Project Explorer, keyboard shortcuts and toolbar icons for check and activate, improved error display, and numerous other small enhancements. 

One of the enhancements to the workflow actually comes outside of the HANA Studio.  There is a new Application Lifecycle Manager web application which is part of HANA. For developers one of the biggest advantages of this new tool is an application creation wizard.  From this tool, a developer can quickly create a Schema, .xsapp, .xsaccess and even a local developer role which already has the necessary package and schema access rights. 

For a quick overview of these various tool improvements and how they streamline the development process, have a look at the following video.

Browser Based IDEs

One of the new features of SAP HANA SPS6 is the inclusion of new browser based development tools for SAP HANA native application development. These tools make it fast and easy to get started creating html, server side JavaScript, and OData services directly within SAP HANA. 

No longer are you required to install the SAP HANA Studio and Client if you only need to do some basic development object creation or editing in the SAP HANA Repository. This means you can be coding your first application within seconds of launching a SAP HANA instance.

The usage of such browser based development tools is particularly appealing to cloud-based SAP HANA development scenarios, like SAP HANA one.  You only need access to the HTTP/HTTPS ports of the SAP HANA server and avoid the need for any additional client side software installation. A browser pointed at the SAP HANA server is all you need to begin development.

On the openSAP forums, I was recently asked why SAP decided to invest in browser based tools when we already have SAP 

HANA Studio. I'm going to plagiarize myself and repost the response here:

Web IDEs require no installation on the client side.  So if you are using a MacOS device today, you can't use HANA Studio for development tasks as it isn't supported (has no REGI / HANA client). Therefore the Web IDE offers an alternative if your OS doesn't support Studio.

Web IDEs run on the HTTP port. Especially in the cloud usage scenario, it’s probably easier to get this port open rather than the various ports used by the Studio. 

Web IDEs work on mobile devices. No you probably don't want to develop day to day on a mobile device, but what if you get a support call in the middle of the night?  It’s a great way to quickly check on something. I've used it to fix a demo in the middle of an event from my phone.  

Web IDEs are good for system admins that might want to only change a xsaccess file.  Even if they have HANA Studio, they will probably feel more comfortable with the direct edit/save workflow of the Web IDEs rather than the project check out /commit /activate of the HANA Studio. 

The Web IDEs allow you to delete even the .project file and .settings folders from repository packages. HANA Studio can't do this and commit back to the repository because these are key files to the project itself.  Therefore the Web IDEs can be used to clean up a package and make it ready for complete deletion.

Core Data Services (CDS) / HDBDD

Core data services (CDS) is a new infrastructure for defining and consuming semantically rich data models in SAP HANA. Using a a data definition language (DDL), a query language (QL), and an expression language (EL), CDS is envisioned to encompass write operations, transaction semantics, constraints, and more.

A first step toward this ultimate vision for CDS is the introduction of the hdbdd development object in SPS6. This new development object utilizes the Data Definition Language of CDS to define tables and structures. It can therefore be consider an alternative to hdbtable and hdbstructure. In the following video we explorer the creation of several tables within a single hdbdd design time artifact. 

Server Side JavaScript Outbound Connectivity

Server Side JavaScript (XSJS) was already the cornerstone of creating custom services within HANA to expose data to the outside world. In SPS6, the primary programming model of the HANA Extended Application Services gets outbound connectivity support as well.  Now developers can  call out of the HANA system and consume services via HTTP/HTTPS from other systems. This can be a way of combining real-time data from multiple sources or gathering data to store into SAP HANA.

In the following video we show two scenarios - calling to an ABAP system to get additional user details and consuming a Library of Congress image search services.  These are just two simple examples of the power of this new capability.

XSODATA Create/Update/Delete

Similar to the role of XSJS in SPS5, XSODATA services are already established as the quickest and easiest way to generate read-only REST services from existing tables and views within HANA. In SPS6, those capabilities are complemented with new support for Create, Update, and Delete operations as well.  No longer are you required to create a custom service in XSJS if you only need to add simple update capabilities to your service. Furthermore, if you need some simple validation or other update logic; it can be coded in a SQLScript exit mechanism from within the generic XSODATA service framework.

This video demonstrates these new Create/Update/Delete capabilities, a useful test tool for Chrome called Postman, and even how to use the SQLScript extension technique.

Source Code

Here are the various source code segments if you wish to study them further

The USER.hdbdd CDS example:

namespace sp6.data;
@Schema: 'SP6DEMO'
context USER {
           type SString : String(40);
           type LString : String(255);
   @Catalog.tableType: #COLUMN
     Entity Details {
               key PERS_NO: String(10);
               FIRSTNAME: SString;
               LASTNAME: SString;
               E_MAIL: LString;
     };
};

The popUsers.xsjs:

function insertRecord(userDet){
          var conn = $.db.getConnection();
          var pstmt;
          var query =
          'UPSERT "sp6.data::USER.Details" ' +
            'VALUES(?, ?, ?, ?) ' +
             'WHERE PERS_NO   = ? ';
          pstmt = conn.prepareStatement(query);
          pstmt.setString(1, userDet.ITAB.PERS_NO);
          pstmt.setString(2, userDet.ITAB.FIRSTNAME);
          pstmt.setString(3, userDet.ITAB.LASTNAME);
          pstmt.setString(4, userDet.ITAB.E_MAIL);
          pstmt.setString(5, userDet.ITAB.PERS_NO);
          pstmt.executeUpdate();
          pstmt.close();
          conn.commit();
          conn.close();
}
function populateUserDetails(){
          var user = $.request.parameters.get("username");
          var dest = $.net.http.readDestination("sp6.services", "user");
          var client = new $.net.http.Client();
          var req = new $.web.WebRequest($.net.http.GET, user);
          client.request(req, dest);
          var response = client.getResponse();
          var body;
          if(response.body){body = response.body.asString(); }
          $.response.status = response.status;
          $.response.contentType = "application/json";
          if(response.status === $.net.http.INTERNAL_SERVER_ERROR){
                    var error = JSON.parse(body);
                    $.response.setBody(error.ITAB[0].MESSAGE);
          }
          else{
                    var userDet = JSON.parse(body);
                    insertRecord(userDet);
                    $.response.setBody('User ' + userDet.ITAB.FULLNAME + ' Personel Number: ' + userDet.ITAB.PERS_NO + ' has been saved' );
          }
}
populateUserDetails();

The searchImages.xsjs:

function searchImages(){
          var search = $.request.parameters.get("search");
          var index = $.request.parameters.get("index");
          if(index === undefined){
                    index = 0;
          }
          var dest = $.net.http.readDestination("sp6.services", "images");
          var client = new $.net.http.Client();
          var req = new $.web.WebRequest($.net.http.GET, search);
          client.request(req, dest);
          var response = client.getResponse();
  var body;
          if(response.body){body = response.body.asString(); }
          $.response.status = response.status;
          if(response.status === $.net.http.INTERNAL_SERVER_ERROR){
                    $.response.contentType = "application/json";
                    $.response.setBody('body');
          }
          else{
                    $.response.contentType = "text/html";
                    var searchDet = JSON.parse(body);
                    var outBody =
                              'First Result of ' + searchDet.search.hits + '</br>'+
                              '<img src="' + searchDet.results[index].image.full + '">';
                    $.response.setBody( outBody );
          }
}
searchImages();

The user.xsodata:

service namespace "sp6.services" {
   "sp6.data::USER.Details" as "Users"
      create using "sp6.procedures::usersCreateMethod";
}

The usersCreateMethod.procedure:

CREATE PROCEDURE _SYS_BIC.usersCreateMethod(IN row SYSTEM."sp6.data::USER.Details", OUT error tt_error)
          LANGUAGE SQLSCRIPT
          SQL SECURITY INVOKER AS
BEGIN
/*****************************
          Write your procedure logic
*****************************/
declare lv_pers_no string;
declare lv_firstname string;
declare lv_lastname string;
declare lv_e_mail string;
select PERS_NO, FIRSTNAME, LASTNAME, E_MAIL
     into lv_pers_no, lv_firstname,
          lv_lastname, lv_e_mail
                      from :row;
if :lv_e_mail = ' ' then
  error = select 400 as http_status_code,
               'invalid email' as error_message,
                     'No Way! E-Mail field can not be empty' as detail from dummy;
else
  insert into "sp6.data::USER.Details"
             values (lv_pers_no, lv_firstname,
                     lv_lastname, lv_e_mail);
end if;
END;

ABAP Service Implementation:

TRY.
     DATA(lr_writer) = cl_sxml_string_writer=>create(
         type = if_sxml=>co_xt_json ).
     DATA(ls_address) = zcl_user=>get_details( iv_username = to_upper( me->username ) ).
     CALL TRANSFORMATION id SOURCE itab = ls_address
                                RESULT XML lr_writer.
     lv_json = cl_abap_codepage=>convert_from( CAST cl_sxml_string_writer( lr_writer )->get_output( ) ).
   CATCH zcx_user_error INTO DATA(lx_user_error).
     CALL TRANSFORMATION id SOURCE itab = lx_user_error->return
                              RESULT XML lr_writer.
     lv_json = cl_abap_codepage=>convert_from( CAST cl_sxml_string_writer( lr_writer )->get_output( ) ).
     response->set_status( code = 500
                           reason = CONV #( lx_user_error->return[ 1 ]-message ) ).
ENDTRY.

ABAP Class ZCL_USER:

class ZCL_USER definition
  public
  create public .
  public section.
    class-methods GET_DETAILS
    importing
      !IV_USERNAME type BAPIBNAME-BAPIBNAME
    returning
      value(RS_ADDRESS) type BAPIADDR3
    raising
      ZCX_USER_ERROR .
protected section.
private section.
ENDCLASS.
CLASS ZCL_USER IMPLEMENTATION.
  METHOD get_details.
    DATA lt_return TYPE STANDARD TABLE OF bapiret2.
    CALL FUNCTION 'BAPI_USER_GET_DETAIL'
      EXPORTING
        username = iv_username    " User Name
      IMPORTING
        address  = rs_address    " Address Data
      TABLES
        return   = lt_return.    " Return Structure
    IF lt_return IS NOT INITIAL.
      RAISE EXCEPTION TYPE zcx_user_error
        EXPORTING
          return = lt_return.
    ENDIF.
  ENDMETHOD.
ENDCLASS.
71 Comments
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

No, there is no functionality yet to perform asynchronous outbound requests. We have talked about adding this, but requires changes to the threading model. We've begun to make those changes in SPS09 and the first product of that is a followUp function for the response object. Eventually we want to extend this to be a callaback for outbound requests as well.

former_member205429
Contributor
0 Kudos
Hi Thomas,

Very nicely explained.

I followed the exact steps to expose the ABAP Class to XSJS using Outbound Connectivity. But have couple of queries here :

  1. when i execute the BSP Page, a notepad is getting generated. any clue on how to suppress that and instead display the results in the same page.?

  2. when exposing the BSP to HANA XSJS,I am getting 500 error. any clue as to why this error is getting. BSP application is working perfectly but when executing the .xsjs file, i am getting the 500 error. any clue on how to resolve this please.


Thank You,

Santhosh
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
You haven't said anything about your BSP page, so how could I diagnose what is wrong with it.

 

500 is internal server error. Is that error coming from XSJS or from the BSP page?  Have you debugged to see where the error is even thrown from?
former_member205429
Contributor
0 Kudos
Hi Thomas,

Thank you for your quick response.

My BSP Page is as below :







when i execute the BSP APplication directly by right clicking + Test service, i am getting the expected output from the abap class. while attempting to execute from the XS HANA only i am getting the error.

Below is the code from XS HANA Repository :

XSHTTPDEST file :



below is the code from .XSJS file



 

Upon Executing the .xsjs from XS HANA Web Development - i get the 500 error. Request you to please observe the host and port details in the below URL as well :



 

I wish to let you know that i have created few other XSJS files, XSODATA files to read data from the attribute views, Tables from the Data base, CRUD operations on the tables, and few others from SAP HANA Web Development URL. it worked in all the cases.

I believe there is some link missing  between HANA XSJS and BSP Application as i see different host details in the URL.

Also i am new to XSJS, and request you to kindly co-operate.

Thank You.

Santhosh

 

 
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
Turn off the "Friendly" error messages by activating developer_mode on the XSEngine.  Then you will get technical details about what the error is and where it was produced from instead of the generic 500 error screen. Also in your xshttpdest, you can't have the http:// on the front of the hostname.
former_member205429
Contributor
0 Kudos
HI Thomas,

I configured developer_mode and removed the http:// in the host.

upon re-executing the xsjs file, i got the below error:

 



Request you to please advise if there is anything i am missing.

 

Thanks.

Santhosh
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
The error is from your WebRequest constructor which tells me there is something wrong with the value in the location variable.  Perhaps it isn't getting pulled in from the request object. You don't seem to be passing anything on the URL according to your screenshot so this variable would be null. That would be a problem.
former_member205429
Contributor
0 Kudos
Thomas,

i tried to construct the url as below :

http://cinl08p145:8000/OData_T1/re2database/get_locations.xsjs?location=0009

 

and i get the below error :

 

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
Sounds like something is still wrong with your URL building.  Are you sure there's no proxy?  Port correct?  Something's wrong, but as I don't know you systems I can't possibly say.
former_member205429
Contributor
0 Kudos
Thomas,

I tried different options to change the Port and host.

sometimes i get the below response. Are there any other check points in the HANA Administration ? kindly advise so that i can check.

 

Thank You.

 

<html>
<head>
<title>Error 404 - Not found</title>
<style>
body {
color: #F0AB00;
font: 12px Arial,Helvetica,sans-serif;
background-repeat: no-repeat;
background-size: 100%;
height: 100%;
margin: 0;
background: #000000; /* Old browsers */
background: -moz-linear-gradient(top, #000000 55%, #666666 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(55%,#000000), color-stop(100%,#666666)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #000000 55%,#666666 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #000000 55%,#666666 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, #000000 55%,#666666 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#666666',GradientType=0 ); /* IE6-9 */
background: linear-gradient(#000000 55%,#666666 100%); /* W3C */
}
#content {
background: #ffffff; /* Old browsers */
background: rgba(240, 171, 0, 0.9);
border: #FFFFFF 1px solid;
color: #222222;
position: absolute;
top: 50%;
left: 50%;
margin-left: -300px;
margin-top: -100px;
width: 600px;
height: 200px;
padding: 10px;
font-size: 17px;
-webkit-box-reflect: below 10px -webkit-gradient(linear, 0 0, 0 100%, from(transparent), color-stop(.66, transparent), to(#FFF));
}
#footer {
position: absolute;
bottom: 0px;
left: 50%;
text-align: center;
width: 220px;
margin-left: -110px;
}
#error h1 {
font-weight: normal;
font-size: 28px;
margin-bottom: 20px;
margin-top: 0;
color: #ffffff;
}
#solution {
position: absolute;
bottom: 10px;
left: 10px;
}
#solution h2 {
font-weight: bold;
font-size: 16px;
color: #ffffff;
}
#left {
width: 480px;
float: left;
}
#right {
position: absolute;
top: 0;
right: 0;
color: rgba(0,0,0,0.2);
width: 120px;
float: right;
font-size: 200px;
padding-top: 0;
}
</style>
<!--[if lt IE 9]>
<style>
body {
background: #000000;
}
#content {
background: #f0ab00;
}
</style>
<![endif]-->
</head>
<body>
<div id="content">
<div id="error">
<div id="left">
<h1>404 - Not found</h1>
We could not find the resource you're trying to access.<br/>
It might be misspelled or currently unavailable.
</div>
<div id="right">?</div>
</div>
<div id="solution">
<h2>Possible solution</h2>Please check the URL or try again later.<br/>
In case of ongoing problems please contact your system administrator.
</div>
</div>
<div id="footer">
powered by
<img src="data:image/gif;base64,R0lGODlhHwAQAOeKABxivBtlwBpmwBtmvxlqwBlqwRlrwhhuwxhvxBZ1yBN8zBR9zCB6yhCCzhGCzxODzw6I1A+I0xuH0RSK1A2N2BaL1A2P1wuT2xSR2AuU2z6Hzg+W3AqZ3gma3hWY3BaZ3Qef4geg4gih4h6b3gyi4wal5QWm5gen5lKT0x6j4R+j4g2p5wOs6QSs6QKx7QGy7QC38ECm32Kd11Cj3GKi2l2l3GWk216m3D2v5Tiz6DK260Oy5lKu4lSv43Oo20a46U+351605FK46HC04me45ni04n+z4We86Xe85oy34nTC65S85GnK8GrK8KPF53zQ8pHM7YvP75LS8JzR76jP7KXQ7Y3X9KDT75PZ9JjY86vT7qjU75/X8qrV75zZ87fS7KrX8aPZ86nZ8qjb86fd9bfZ8b/X76fg9q/i98De8rDj98Lh9Mfj9brn+Lzn+MDp+dTm9cjq+c/q+Nno9tjp99fr+Nft+dzt+N/u+eDu+N7w+uHw+dzy+9/y++jx+ufy+uTz++j1/PP5/fT6/fX6/fb6/ff6/fv9/vz+//3+/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////yH5BAEKAP8ALAAAAAAfABAAQAj+AP/BGEiwoMGDCGH8gzAByR5FELesUbQmQh1FXbpA3Mimwr+PID+CyLIRopcQPzbmCEGmpKI4JELIFBHygIYlX8w4QeHEiQwEQH30dJIEQcijIFuwWMq0qdOnT0GOQKRIzxEPGTJ8GKRIjqJAG8QospNhA1UlGS4gXVCESo0beVyWNKSIjoK7SEMGGMC3r9+/AvLmdfGisOHDiBMr/mjiRJM2fN5Y0dEYjZszJkw8ceNGDRYmKzKLLgFSRSJFXHAI4ZKiQ5iNUjqMUdRnRxSIQDp04HDUwpWNgqBgIKLoUAyIPMAoAhRkCsQeFPI2cODgwYw7xU/jqfJHUaEyiggvpdEyRILgfwz8lDwEEY4NIzTUQ5yTIMH5jwYK6N/Pv38BAveFBMCABBZYYIBHBQQAOw==">
XSEngine
</div>
</body>
</html>
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
I can't possibly tell you what the correct host, port, etc are for your systems.
former_member205429
Contributor
0 Kudos
Thank you Thomas. i will update once the issue is resolved.
former_member205429
Contributor
0 Kudos
Hi Thomas,

I tried to figure out errors i got earlier but got stuck here.

Request you to kindly advise looking at the below error if possible please.



Thanks,

Santhosh

 
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
BSP perform a URL rewrite upon first request. They mangle the URL to place the authentication and other information into the URL. I assume the first status you get back from BSP is probably the redirect status. Your HTTP client will need to be able to handle this.  If you don't want to deal with BSP URL mangling, then I suggest using a ICM handler class on the ABAP side for your service.
former_member205429
Contributor
0 Kudos
Hi Thomas,

i referred to few blogs on how to pass table of records to the ABAP FM from .XSJS but could not figure out.

https://archive.sap.com/discussions/thread/3354703

https://archive.sap.com/discussions/thread/3695069

My logic is as below :

  1. read partner, source, target from url, build internal table with the same structure and append the values to the internal table and pass it to the ABAP FM.


attached is the code logic :



URL :

XXXXXXXX:8000/OData_T1/createrequest/create_vtrrequest.xsjs?source=0001&target=0001&partner=0050000150

Error :



 

can you please advise on the approach.

 

Thanks,

Santhosh
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
deep_entity(0) isn't proper JavaScript.  Parenthesis are for passing parameters into a function call.  If you want to access the first entity in an object the you use the square brackets [0].
former_member205429
Contributor
0 Kudos
Thomas,

i changed the code as advised by you. but i received the error as shown below.

my only intention to write the below logic is to append 1st record into an array OUT [].

out.push(deep_entity[0]);

 





 

Request you to please advise.

 

Thank You.

Santhosh
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
In both cases of the variable out and deep_entity, you aren't creating arrays.  You are creating a single object.

https://www.w3schools.com/js/js_object_definition.asp

https://www.w3schools.com/js/js_arrays.asp

 

If you want an array then define out like:

var out = [];

And if you want to access a multiple records in deep_entity it should be:

var deep_entity = [{ "partner: partner, "source": source, "target": target };

Or if deep_entity is only going to have the one record then go ahead and initialize it with just the {...}, but then you don't need to reference the record number in the push operation.

I think you might want to study some of the basics of JavaScript syntax. There are some great online resources such as those I liked to above.
Former Member
0 Kudos
Hello Thomas , Could you please tell me where can I set the developer mode in XS Engine
Former Member
0 Kudos
Hi Santhosh, Please tell me how you were able to resolve the Error 500 here. Also I did not find the developer option in the http server configuration
thomas_jung
Developer Advocate
Developer Advocate
0 Kudos
xsengine.ini -> httpserver -> developer_mode = true