Skip to Content

With the introduction of Suite on HANA, ABAP developers will need to branch out a bit more and extend their skills into the database.  We’ve discussed the concept of code push down for quite some time now, and if it hasn’t sunk in yet, let me remind you again with this blog.  ABAP based applications can run faster on HANA without modification as long as the bottleneck is not the application server itself.  If your ABAP program is simply bringing massive amounts of data from HANA into the ABAP application server, and you are doing a LOOP over that data and doing some calculation, then you are not really using the full potential of HANA.  We need to take that data intensive logic and rewrite it in SQLScript and push that logic into the database for faster processing, leveraging the massive parallel processing capabilities of HANA.  So if we are integrating SQLScript procedures into our ABAP applications running on top of HANA, of course we need to be able to debug the procedures in-line with our ABAP applications.  As of HANA 1.0 SPS06(Rev 60), we now support the concept of external session debugging. In this blog, I will concentrate on debugging from ABAP, but the external session debugging is not specific to ABAP, and can be used to debug from other sources as well. 

In this example, I have a procedure called GET_PRODUCTS which accepts an input parameter called IM_PRODUCT which is used as a filter value, and returns one export parameter called EX_PRODUCTS.  The code of this procedure is rather simple, it reads the “Products” table based on the “Product Id” filter and returns a list of products.

CREATE PROCEDURE get_products ( in im_product nvarchar(20),

                                out ex_products tt_products_list )

       LANGUAGE SQLSCRIPT

       SQL SECURITY INVOKER

       READS SQL DATA AS   

BEGIN

/*****************************

       Write your procedure logic

*****************************/

ex_products = select “ProductId”, “Category”, “Price”

                 from “SAP_HANA_EPM_DEMO”.“sap.hana.democontent.epm.data::products”

                       where “ProductId” like im_product

END;

There are two ways to call a procedure from ABAP.  You can use ADBC(ABAP Database Connectivity) to call your procedure or use the new “Database Procedure Proxy” method which was introduced in NetWeaver 7.40.  Debugging  from ABAP into SQLScript works the same way whether you call it via ADBC, or use a proxy. For this example, I have created a Database Procedure Proxy called ZGET_PRODUCTS for this procedure.

/wp-content/uploads/2013/07/1_238516.png

I have also created an ABAP program which calls this “Database Procedure Proxy”.   Here I am passing P_PROD which is a PARAMETER and has the product filter value. LT_PRODUCTS is an internal table defined with the same structure as the EX_PRODUCTS exporting parameter.

/wp-content/uploads/2013/07/2_238517.png

Now that I have all of the components of my application, I can start debugging from my ABAP program straight into the SQLScript procedure in HANA.  In the SQLScript Debug configuration screen, I can set the external session parameters.  In this dialog is where you set the HANA server which is sitting under your ABAP system. The “HANA User” value would be the SAP<sid> user id which ABAP uses to talk to the database.  The “Application User” would be the user id which the developer uses to log on to the ABAP system.

/wp-content/uploads/2013/07/3_238518.png

Once the configuration is complete, click the “Debug” button.  Next, I can set the breakpoints in the procedure and switch to the “Debug” perspective.  Notice there is a debug session running which is simply waiting for ABAP.

/wp-content/uploads/2013/07/4_238519.png

Next, I return to my ABAP program and set a breakpoint on the CALL DATABASE PROCEDURE statement and run the program.  Once I execute the CALL DATABASE PROCEDURE statement from the debugger, control is then passed to the SQLScript debugger in HANA Studio.  You can see that the input parameter value has been passed to the procedure and you can see this value in the “Variables” tab of the SQLScript debugger. From here I can debug the procedure as normal, and when complete, control is passed back to the ABAP application.

/wp-content/uploads/2013/07/5_238520.png

Check out the video demonstration on the SAP HANA Academy.

To report this post you need to login first.

6 Comments

You must be Logged on to comment or reply to a post.

  1. Kamal Mehta

    Hi Rich ,

    Thanks.

    Can you please help and elaborate more on Database Procedure Proxy .How and where  to create the same.

    Regards

    Kamal

    (0) 
    1. Rich Heilman Post author

      Database Procedure proxies are something new in NW 7.4 and can only be created if the ABAP system uses HANA as the primary database.  You create these proxies in ABAP in Eclipse. You specify the object name and the procedure which the proxy is to be created for.  You can then use the CALL DATABASE PROCEDURE statement to directly call the procedure in HANA.

      http://help.sap.com/abapdocu_740/en/abensql_script.htm

      Cheers,

      Rich Heilman

      (0) 
  2. Bonnie Barker

    Hi Rich,

    This is a great addition.  Should it also be possible to step through a procedure when doing external debugging like this?  I appear to only be able to stop at a breakpoint and then resume or quit.

    Regards,

    Bonnie

    (0) 
    1. Rich Heilman Post author

      SQLScript debugging currently only supports stopping at breakpoints, so no step through.  If you want to step, you have to set breakpoints at each statement.  Step through functionality is in the backlog of feature requests.

      Cheers,

      Rich Heilman

      (0) 
  3. Jose Luis Menendez Calderon

    Hi Rich,

    Thank you very much for the Article.

    Do you know if it is posible to debug stored procedures with calculation engine functions in the code?

    it seems when the debug steps to a CE function, the window where variables are shown lose the reference of variables and gets empty.

    Regards

    (0) 

Leave a Reply