Skip to Content
Author's profile photo Thomas Jung

SAP HANA SPS6 – Various New Developer Features

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.

Assigned Tags

      71 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Vivek Singh Bhoj
      Vivek Singh Bhoj

      Excellent Blog Thomas!

      Thanks for even sharing the code here, its very helpful.

      Regards,
      Vivek

      Author's profile photo Former Member
      Former Member

      Hi Thomas.

      Good explanation.

      Seems to me that SAP  going  forward to a modern up to date development IDE.

      what are going to be the coincidence on the old ABAP code?

      does the current world of SAP transactions going to be changed?

      it will be good if you will explain how all of this HTML5 , JavaScript and all

      the other new features will be merged with the old transactions world.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      >what are going to be the coincidence on the old ABAP code?

      Have a look at the service example I built in ABAP.  The tooling is moving to Eclipse as well which is great for an integrated experience with HANA and other tooling.  The ABAP syntax continues to evolve as well. Not just with new features for HANA but many other syntax enhancements.

      >does the current world of SAP transactions going to be changed?

      Existing ABAP code will run on HANA. However to fully leverage the advantages of HANA you may want to rewrite some portions.  We call this code push down. You take parts of the ABAP code and rewrite it as SQLScript procedures or as HANA Views. You then call these artifacts from ABAP.  You might also be able to optimize simply by writing more efficient Open SQL in ABAP.  The whole idea is allow more of the data intensive processing to happen in the database.


      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      Thanks for your excellent blog, as always.

      I assume, during the code push down period, either by rewrite some portions of ABAP or more efficient Open SQL in ABAP, you will have to debug and ckeck the execution plan or trace when needed on 2 places?

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      Yes, but to help with this we have pass-through debugging from ABAP to SQLScript. See a video of this in Rich Heilman's blog:
      http://scn.sap.com/community/developer-center/hana/blog/2013/07/02/sqlscript-debugging-from-external-session

      Author's profile photo Former Member
      Former Member

      Thanks Thomas

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

       

      first of all thanks for your excellent blog and support in the OpenSAP
      Course regarding SAP HANA Development.
      It's always very interesting.

       

      May I ask, is it intended to extend the SAP HANA Eco System with
      additional Projects from the Eclipse Universe, as it was done with the Eclipse
      ORION online Editor?

      Especially is it intended to implement “Contracts” for ABAP, XSJS and other
      HANA software technologies?

      On Eclipse Demo Camp 2013 in Walldorf there were eg. talks about

      • "Contracts for Java in Eclipse (C4J) " and,
      • "Stardust - a full blown BPM Platform under EPL
        (Workflow, Document Processing, System Integration)"

      which are recently Eclipse Project, but not Part of SAP Projects.

      Thanks in advance.

      Frank

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      >May I ask, is it intended to extend the SAP HANA Eco System with

      additional Projects from the Eclipse Universe, as it was done with the Eclipse

      ORION online Editor?

      We are always looking to reuse something which already exists rather than re-invent it. But even reusing additional Eclipse features/projects often takes some effort and therefore must be evaluated alongside all other features we have in our product backlog.

      >Especially is it intended to implement “Contracts” for ABAP, XSJS and other

      HANA software technologies?

      I can't speak for ABAP. That would have to be address to the NetWeaver colleagues.  For HANA Studio/XSJS we do not have this feature in our backlog at this time.

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      As always masterpiece. Thanks  🙂

      Kulwinder

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      As always excellent explanation.

      Thanks for putting up all the videos and code.

      Ravindra

      Author's profile photo Kumar Mayuresh
      Kumar Mayuresh

      Hi Thomas

      Thanks a lot for explaining the key features from SAP HANA SPS6 from developer POV.

      Regards

      Kumar. 

      Author's profile photo Uwe Fetzer
      Uwe Fetzer

      It seems after all these HANA years you are still the ABAP_freak, I like esp. the "ABAP Service Implementation" (7.40).

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      I have to admit I had a lot of fun writing that little block of ABAP. JSON parsing in the kernel, implicit typing, casting types to interface parameter types, direct record access in an internal table: I made it a personal challenge to see how many of the new 7.40 language features I could pack into that little sample.

      Author's profile photo Uwe Fetzer
      Uwe Fetzer

      I can see your smile in the code 🙂

      Author's profile photo Syambabu Allu
      Syambabu Allu

      Nice Explanation...

      Author's profile photo Christiano José Beltrão Magalhães
      Christiano José Beltrão Magalhães

      Hi Thomas, the HANA Developer Edition in the AWS will be updated to SPS 6 ?  😎

      Thanks for this blog.

       

      Christiano.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      Sorry, but I couldn't comment on the timelines of the update of the Developer Edition images offered here on the Developer Center. Someone from the Developer Center team would have to comment on that.

      Author's profile photo Henrique Pinto
      Henrique Pinto

      Juergen Schmerder mentioned in Twitter it would be, "very very soon":

      https://twitter.com/schmerdy/status/350753417137893376

      Author's profile photo Christiano José Beltrão Magalhães
      Christiano José Beltrão Magalhães

      Very nice !!!! 🙂

      Author's profile photo Aby Jacob
      Aby Jacob

      Huge Thanks Thomas !!

      You make our HANA Learning so much Fun; Appreciate all the time & effort

      Author's profile photo Srinivasulu Reddy Tanguturi
      Srinivasulu Reddy Tanguturi

      Thanks Thomas

      Nice explanation

      Great Job

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      Thanks for this blog.Very useful

      I read that create trigger statement has been changed now.

      I would like to know if any changes made in the following

      1. Can We call any new funtions in the DDL statements. Previously only current date and current user can be called in DDL. Does SPS6 supports any additional functions like SYSUUID

      2. Can we now update the subject table within the trigger?

      3. Can we now call procedures within the trigger?

      More details in http://scn.sap.com/thread/3380542

      Thanks

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      I don't cover triggers or any new features in SQL or SQLScript in this blog.  I would recommend that if you are interested in new syntax for triggers that you review the updated SQL reference guide:
      http://help.sap.com/hana/SAP_HANA_SQL_Reference_en.pdf

      Author's profile photo Former Member
      Former Member

      Hi Thomas:

      where can I download the 32-bit sap hana client revision 60, which would provide the file regi.exe?

      Thanks!

      Author's profile photo Vivek Singh Bhoj
      Vivek Singh Bhoj

      HI Zhang,

      At present you can download HANA Rev 60 only from SAP Marketplace

      Author's profile photo Former Member
      Former Member

      Hello Thomas,

      Thanks for updated SQL reference guide.Waiting for see more from you.

      Thanks

      Katrice

      Author's profile photo Vigneswararao Vankayala
      Vigneswararao Vankayala

      Very Nice Blog 🙂

      But I remember that was year 2001, Microsoft introduce .NET framework and given same type of example for the Managed and unmanaged Code 🙂

      Looks SAP also going same direction 🙂

      Thanks

      Rao

      Author's profile photo Former Member
      Former Member

      Hi,

      Very Good information

      Regards,

      Koti.

      Author's profile photo Former Member
      Former Member

      Guys! SP6 is already available in SmartCloudPT Instances (with an upgrade on the minimum size machines to 20GB RAM)!

      http://scn.sap.com/docs/DOC-33267

      Author's profile photo Tobias Munk
      Tobias Munk

      Hi Thomas,

      Thanks a lot!

      I would like to use the second browser-based IDE you introduced, located in:

      sap/hana/xs/ide/

      However, in our HANA system (version 1.00.60.378725), it's not there.

      Do we have to import a specific DU?

      Thanks,

      Tobias

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      Yes the browser based IDEs are both non-automatic content. That means that the delivery units are on the file system of your HANA server, but just need to be imported. From the Studio you can use File->Import. Then choose Delivery Unit.  On the import screen chose Server.  From the Drop down of the files available on the Server you can choose HANA_XS_IDE.tgz or HANA_XS_EDITOR.tgz.

      Author's profile photo Former Member
      Former Member

      One reason for using the browser-based IDE is that no HanaStudio is available (32-bit Linux). Is it possible to import it without HanaStudio? And, the video does not actually mention the URLs of the browser-based IDE, can you please put them here? Thanks.

      -- Micha

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      >Is it possible to import it without HanaStudio?

      Yes you could perform the import via the browser based HANA Application Lifecycle Manager tool (/sap/hana/xs/lm/).

      >And, the video does not actually mention the URLs of the browser-based IDE

      You can see the URL in my browser address bar.  Here are the URLs as well

      For Lite: /sap/hana/xs/editor/

      For Web Based Development Workbench: /sap/hana/xs/ide/

      Author's profile photo Former Member
      Former Member

      Thomas,

      Thanks for posting the sample code.  The new IDEs are great.  Quick question about outbound connectivity:

      I set up your library of congress image search example and created my own images.xshttpdest.  I used the IDE to create the file, but no matter what the content (even just host and port lines as below) I cannot activate it:

      Error while activating:

      An error occurred during activation of app.second/images : Validation error: Value of variable "port" is not or only partly set.

      Other demo applications are working fine, so it seems that its something related to outbound connectivity.  Any ideas?

      regards,

      Kence

      host = "www.loc.gov";

      port = 80;

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      I cut and pasted that directly from your posting into my system and it activated correctly. What revision is your system?

      Author's profile photo Former Member
      Former Member

      Thanks for checking into this.  The revision is 1.00.60.379371.

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      I'm afraid I don't have much advice to offer you since I can't recreate the problem in my system. You mentioned the Web IDEs. Are you using that to create and activate this file?  Have you tried using the Studio instead?  It should work in both, of course; but I'm trying to narrow down the troubleshooting parameters.

      Author's profile photo Denis Sproten
      Denis Sproten

      Nice feature having an IDE in the browser - but enhancements will need to follow and will it end up to be a full client tool anyway?

      Author's profile photo Former Member
      Former Member

      Thanks a lot Thomas

      For parsing XML response in Outbound Data Connectivity refer this blog Parse XML in server side javascript (XSJS)

      Regards,

      Shreepad

      Author's profile photo Former Member
      Former Member

      Outstanding HANA feature. I have been developing I lot with SP6 new features, but unfortunately I can not go forward without knowing how to solve the following problem:

      Can I update oData entities that have associations with just one request instead of one for each entity? I've tried to use procedure with two input parameters, but I still don't know how the JSON should looks like. 🙁

      Regards,

      Pablo Silva

      Author's profile photo Former Member
      Former Member

      Nice!

      Author's profile photo Former Member
      Former Member

      Nice..very Helpful Thomas

      Author's profile photo Former Member
      Former Member

      I deactivated the Always synchronise local and remote workspaces but it still keeps trying to commit every time I save a file.

      It is very annoying when I try to work offline because every time I have to wait for regi to timeout to the server. I have the server off because I can't have the AWS machine running all the time, specially when working only in UI5 projects, that do not always require connection.

      Is there a way to really deactivate the synchronisation?

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      Of course the setting you mention should work.  However if it isn't for you, I'd suggest just unsharing the project when you are working offline.

      Author's profile photo Former Member
      Former Member

      Thanks Thomas. After several trials, restarting the studio, the computer.... nothing worked... the option appears deactivated, but every time it still tries to connect to the server.

      At the end I started the remote server and unshared the project. Thanks for the workaround.

      I think the regi/hdbstudio integration should try once to connect and if there is no successful connection, then deactivate the automatic synchronisation for the session.  That would be a nice addition to hdbstudio.

      Author's profile photo Former Member
      Former Member

      is there a way to send the Soap Envelope and other request headers. I am trying something like this:

      var client = new $.net.http.Client();

      var req = new $.web.WebRequest ($.net.http.POST,"");

      var soapEnv = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://tempuri.org/">\

                                       <soapenv:Header/>\

                                                        <soapenv:Body>\

                                                                  <tem:TWBGetAllDetails/>\

                                                        </soapenv:Body>\

                                       </soapenv:Envelope>';

      req.setRequestHeader("Content-Type", "text/xml;charset=UTF-8");

      req.setRequestHeader("SOAPAction", "http://tempuri.org/IMyDetailsService/TWBGetAllDetails");

      req.setRequestBody(soapEnv);

      client.request(req, dest);

      I need to send this SOAP header and other information in order to access the webservices from a remote API. What can I do in this regards in the xsjs file. I could not find anything suitable in the HANA guide also.

      Thanks in advance,

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      There is no special support for SOAP offered.  You have to code the headers and envelope yourself as you suggested above.  XSJS only exposes teh Request and the ability to set request headers and body.  What exactly isn't working with the above example?  I can only answer questions about the WebRequest APIs - nothing specific to how SOAP headers or envelope should be constructed.

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      Thanks for a quick reply. I was looking for the equivalents of ".setRequestHeader()" and similar methods in xsjs which I can use to send the request headers and soap envelope. HANA doesnt seem to support the setRequestHeader I believe as it is from Javascript.

      Edit: I found the equivalent methods: its: .contentType and .headers.set and .setBody. 🙂

      req.contentType = "text/xml;charset=UTF-8";

      req.headers.set("SOAPAction","http://tempuri.org/IMyLabWcfService/TWBGetAllDetails");

      req.setBody(soapEnv);

      Author's profile photo Mohammad Anjum Wassan
      Mohammad Anjum Wassan

      Huge THANKS!!

      Keep it up...

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      I have a question about Outbound Connectivity in HANA XS that I couldn't find any answer in the documentation. I know this is an old post but it's the newest I found that mention this topic.

      My question is if it's possible to perform asynchronous outbound HTTP requests from XS Sever-side JavaScript. I'm working in a case where I need to make multiple HTTP calls and I'd like to make them in parallel to speed up the response time.

      Is there any way to do something like this in XSJS? Maybe something like asynchronous functions with callbacks?

      Thank you very much!

      --LUIS

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      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.

      Author's profile photo Santhosh Kadiyala
      Santhosh Kadiyala

      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

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      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?

      Author's profile photo Santhosh Kadiyala
      Santhosh Kadiyala

      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

       

       

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      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.

      Author's profile photo Geetha Gopalakrishnan
      Geetha Gopalakrishnan

      Hello Thomas , Could you please tell me where can I set the developer mode in XS Engine

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      xsengine.ini -> httpserver -> developer_mode = true

      Author's profile photo Santhosh Kadiyala
      Santhosh Kadiyala

      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

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      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.

      Author's profile photo Santhosh Kadiyala
      Santhosh Kadiyala

      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 :

       

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      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.

      Author's profile photo Santhosh Kadiyala
      Santhosh Kadiyala

      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>

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      I can't possibly tell you what the correct host, port, etc are for your systems.

      Author's profile photo Santhosh Kadiyala
      Santhosh Kadiyala

      Thank you Thomas. i will update once the issue is resolved.

      Author's profile photo Santhosh Kadiyala
      Santhosh Kadiyala

      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

       

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      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.

      Author's profile photo Geetha Gopalakrishnan
      Geetha Gopalakrishnan

      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

      Author's profile photo Santhosh Kadiyala
      Santhosh Kadiyala

      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

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      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].

      Author's profile photo Santhosh Kadiyala
      Santhosh Kadiyala

      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

      Author's profile photo Thomas Jung
      Thomas Jung
      Blog Post Author

      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.