Skip to Content
Author's profile photo Shahid Mohammed Syed

Consuming HANA Views, Procedures, External Views in ABAP 7.40 Syntax – Part 3

Part 1: http://scn.sap.com/community/abap/hana/blog/2014/01/08/consuming-hana-views-procedures-external-views-in-abap-740-syntax–part-1


  • ABAP Report with new data declaration syntaxes on 7.40
  • ABAP Report on HANA using ADBC


Part 2:http://scn.sap.com/community/abap/hana/blog/2014/01/08/consuming-hana-views-procedures-external-views-in-abap-740-syntax–part-2

  • Consuming Attribute View using External View.
  • Consuming Attribute View using Native SQL
  • Consuming Analytic View/Calculation View in ABAP


Part 3: http://scn.sap.com/community/abap/hana/blog/2014/01/08/as

  • Consuming HANA artifact Stored Procedure using ABAP Proxy Procedure.
  • Consume HANA artifact Stored Procedure by Calling it in ABAP Code.



T6. Consuming HANA artifact Stored Procedure using ABAP Proxy Procedure.


Steps to create Stored Procedure:

Step 1: Go to ‘Modeler’ or ‘SAP HANA Development ‘prospective and right click on your package and create a new procedure.

Step 2:  Enter name and description, select the ‘Default Schema’ (SAP-SID) and Run With as ‘Invoker’s Right’ and click on finish.

/wp-content/uploads/2014/01/1_358733.jpg

Step 3: Add ‘Output’ and ‘Input’ parameters by right clicking on the respective folders

/wp-content/uploads/2014/01/2_358734.jpg

Step 4: Place the code in the procedure editor

BEGIN

et_last_rev_bill = SELECT empinfo.pernr as PERNR, DAYS_BETWEEN(empbill.BILL_DATE,CURRENT_UTCDATE) AS LAST_REV_BILL

                     FROM DTAB_EMP_INFO AS empinfo INNER JOIN DTAB_EMP_BILL AS empbill

                       ON empinfo.pernr = empbill.pernr

                    WHERE empbill.mandt = empinfo.mandt

                    GROUP BY empinfo.pernr, empbill.bill_date ;

END;

/********* End Procedure Script ************/


/wp-content/uploads/2014/01/3_358735.jpg

Step5: Save and activate the procedure. Execute the procedure in ‘SQL Console’.

Call “_SYS_BIC”.“mohas97_ha5/ZEMP_BILL_PP”(?) WITH OVERVIEW;


Call “_SYS_BIC”.“mohas97_ha5/ZEMP_BILL_PP”(?);

/wp-content/uploads/2014/01/4_358736.jpg

Now create a Proxy Procedure in ABAP:

Step 1: Go to ‘ABAP’ prospective.

/wp-content/uploads/2014/01/5_358737.jpg

Step 2:  Right click on ABAP package under which you want to create this Proxy Procedure. Under ‘New’ click on ‘Other ABAP Repository Object’

/wp-content/uploads/2014/01/6_358738.jpg

Step 3: Choose ‘Database Procedure Proxy’.

/wp-content/uploads/2014/01/7_358739.jpg

Step 4: Enter name, description, HANA s procedure name
/wp-content/uploads/2014/01/8_358740.jpg

Step 5: Now your proxy procedure is created just activate the object.

/wp-content/uploads/2014/01/9_358741.jpg

Source code to Consume the ‘Proxy Procedure’  in ABAP:

  DATA: lt_bill_rev_days TYPE TABLE OF if_emp_bill_proxy_procedure=>et_last_rev_bill,

        lv_count     TYPE i.

  CALL DATABASE PROCEDURE emp_bill_proxy_procedure

IMPORTING et_last_rev_bill = lt_bill_rev_days.

  LOOP AT lt_bill_rev_days ASSIGNING FIELD-SYMBOL(<fs_bill_rev_days>).

    WRITE: / ‘Days Since Bill Rate is changed’ ,<fs_bill_rev_days>-pernr.

    WRITE: ‘=’, <fs_bill_rev_days>-last_rev_bill , /.

  ENDLOOP.

Output:

/wp-content/uploads/2014/01/10_358745.jpg

T7. Consume HANA artifact Stored Procedure by Calling it in ABAP Code.

Source Code


* Calling hana procedure in ABAP
TYPES: BEGIN OF lty_s_overview,
param
TYPE string,
value TYPE string,
END OF  lty_s_overview.

DATA: lt_overview TYPE  TABLE OF lty_s_overview.
DATA: ls_overview TYPE  lty_s_overview.

TRY.

lv_sql = | CALL _SYS_BIC.“mohas97_ha5/ZEMP_BILL_PP”  | &&
|
( null ) WITH OVERVIEW |.

*     execute the native SQL query/ SQL Call
lo_result
= NEW cl_sql_statement( )->execute_query( lv_sql ).   ” new syntax

*     read the result into the internal table lt_partner
GET REFERENCE OF lt_overview INTO lr_data.
lo_result
->set_param_table( lr_data ).  “Retrieve result of native SQL call
lo_result
->next_package( ).
lo_result
->close( ).

* Read internal table
READ TABLE lt_overview INTO ls_overview WITH KEY param = ‘ET_LAST_REV_BILL’.
lv_sql
= ` select * from ` && ls_overviewvalue.
*     execute the native SQL query/ SQL Call
lo_result
= NEW cl_sql_statement( )->execute_query( lv_sql ).   ” new syntax

*     read the result into the internal table lt_partner
GET REFERENCE OF lt_bill_rev_days  INTO lr_data.
lo_result
->set_param_table( lr_data ).  “Retrieve result of native SQL call
lo_result
->next_package( ).
lo_result
->close( ).

CATCH cx_sql_exception INTO lx_sql_exc.
lv_text
= lx_sql_exc->get_text( ).
MESSAGE lv_text TYPE ‘E’.

ENDTRY.

LOOP AT lt_bill_rev_days ASSIGNING FIELDSYMBOL(<fs_bill_rev_days>).
WRITE: / ‘Days Since Bill Rate is changed::’ ,<fs_bill_rev_days>pernr.
WRITE: ‘::’, <fs_bill_rev_days>last_rev_bill , /.
ENDLOOP.

/wp-content/uploads/2014/01/11_358746.jpg

Assigned Tags

      11 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Syed,  I'm Murali an Abaper with 8 and half years of exp. Now planning to learn ABAP Programming on HANA. I have done 2 online certifications on SAP HANA conductedby OPENSAP.com. Need your help on how can i start on ABAP Hana. Please share if you have any documents on the same and let me know if there any related trainings for the same.

      Thank you.

      Murali.M

      Author's profile photo Shahid Mohammed Syed
      Shahid Mohammed Syed
      Blog Post Author

      You can go thru the link what Jasmin Shared

      ABAP for SAP HANA Reference Scenario .

      Author's profile photo Former Member
      Former Member

      Thanks Syed.

      Author's profile photo Patrick Bachmann
      Patrick Bachmann

      Hi Shahid,

      Will this work using HANA as a secondary db to SAP on Oracle?  ie: I want to show our ABAP team how they can consume some of my HANA stored procedures.

      Thanks,

      -Patrick

      Author's profile photo Patrick Bachmann
      Patrick Bachmann

      Shahid, can you also check this other question I have?

      Different ways to create procedures

      Thanks!!

      -Patrick

      Author's profile photo Jasmin Gruschke
      Jasmin Gruschke

      Hi Patrick,
      which way of consumption are you asking about? For sure you can use a secondary DB connection within ADBC and consume the HANA Procedure when HANA is the secondary DB.
      DB procedure proxies you won't be able to create on the secondary DB (only using a programmatical approach). But if the proxy exists (either created via the ADT directly or programatically), you'll again be able to consume it via the connection statements in the CALL DATABASE PROCEDURE call (see e.g. http://scn.sap.com/thread/3517597).
      Cheers,
        Jasmin

      Author's profile photo Patrick Bachmann
      Patrick Bachmann

      Hi Jasmin,

      Thanks for your valuable feedback.  Basically up until now our ABAP team has just been writing sidecar ABAP reports on SAP source system and calling tables directly from HANA as secondary db.  There was immediate improvements in runtime for long reports of course however we want to start doing more code push-down into HANA.

      So our approach is;

      1) Teach them all about HANA and views/models/procedures

      2) Teach them how to consume this from ABAP

      3) We have installed ABAP add-on for studio.

      So I'm not entirely clear if we should focus on A) still writing all the abap from SAP source system and consume HANA views and procedures or B) should we be writing ABAP from within studio with the ABAP add-on.  For now I'd just be happy with showing them option A to at least get them moving so I'm trying to understand which of the methods in these blogs would fit this option A.  It looks like external view would not work and I'm not 100% clear of passing parameter(s) to a procedure will work with option A as well with HANA as secondary db?

      Many thanks!

      -Patrick

      Author's profile photo Jasmin Gruschke
      Jasmin Gruschke

      Hi Patrick,
      I don't have the ultimate answer to your question, so if you have 99% side-car scenarios and only 1% scenarios, where you have an "ABAP-based system on HANA as primary DB architecture", I think your approach is perfectly fine. We (well, me and the team around) rather focus on the latter, which is e.g. also the case for S/4HANA etc. In that case, I'd strongly recommend to take the "top-down-approach" path.
      I typically refer to our openSAP course ABAP Development for SAP HANA - Dr. Jasmin Gruschke and Jens Weiler, but that's (as mentioned above) mainly targeting for the ABAP-based system on HANA as primary DB case.
      Cheers,
        Jasmin

      Author's profile photo Former Member
      Former Member

      What shall I say about it ... ? 😉

      It's the best I found and solve a lot of my problems.

      Thank you soooo mutch. 🙂

      Best Regards

      Author's profile photo Shahid Mohammed Syed
      Shahid Mohammed Syed
      Blog Post Author

      Thank you

      Author's profile photo Former Member
      Former Member

      Creating procedure in this way seems to have been deprecated! Do you have any idea how to consume SP , created as a repo object, and consume in ABAP ? Because the SP is not shown,created as repo object, in the procedure list while creating procedure proxy!