Technology Blogs 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: 
0 Kudos
Here, we will access the HANA Sandbox system from an ABAP system. The ABAP system has database like MaxDB. We will access HANA DB (HDB) from this ABAP system as a secondary DB.
This is the example which connects ERP system with HANA system.
Pre-condition(s):
SAP HANA DBSL is needed (this is the Database specific library which is part of the ABAP Kernel). The SAP HANA DBSL is only available for the ABAP Kernel 7.20, which is already the kernel for NetWeaver 7.02, 7.03, 7.20, 7.30 and 7.31. So make sure, the ABAP system you use has valid release of Netweaver.
 
Steps:
  1. Create Connection:
    • Create/Get a user (prefer a generic user) in HANA sandbox:  I created ‘EBSCLNT001’.

              

              
    • Note the connection (host) information from HANA Sandbox:


    • Create DB connection in ABAP system: Transaction SM30, table DBCON.  You need to give the HANA Sandbox username/password created in step 1(a). Give the connection information from step 1 (b). Give a connection name such as ‘HANA_COE_EBS’.


     2. In the user specific schema, you need to create your own tables/views etc., manually/programatically (via ABAP). Table SFLIGHT created in schema EBSCLNT001.
        
    
     3.  Accesing this table from ABAP Program (ABAP System where DBCON setting was done):

Sample code:
DATA: flight TYPE sflight,
      t_flight 
LIKE TABLE OF sflight,
      wa_flight
LIKE LINE OF t_flight.

* Single Record
SELECT SINGLE * FROM sflight INTO flight
  CONNECTION
('HANA_COE_EBS') WHERE carrid = 'AA'.
IF sy-subrc IS INITIAL.   WRITE: / 'Successful access to HANA Sandbox COE!',/,/ENDIF.

* Multiple records from HANA table
SELECT * FROM sflight INTO TABLE t_flight CONNECTION ('HANA_COE_EBS').
WRITE: /'Data from Table SFLIGHT, no. of records: ', sy-dbcnt.
LOOP AT t_flight INTO wa_flight.
 
WRITE: / wa_flight-carrid, wa_flight-connid, wa_flight-fldate.
ENDLOOP.

Execute: You will get all the records!

You can try this with any ABAP system with appropriate Netweaver release and HANA Sandbox.
 
Also refer the blog(s) here for more detailed information:
    
    
3 Comments