Skip to Content

Introduction

In this first edition of this HANA Developer’s Journey I barely scratched the surface on some of the ways which a developer might begin their transition into the HANA world. Today I want to describe a scenario I’ve been studying quite a lot in the past few days: accessing HANA from ABAP in the current state.  By this, I mean what can be built today.  We all know that SAP has some exciting plans for ABAP specific functionality on top of HANA, but what everyone might not know is how much can be done today when HANA runs as a secondary database for your current ABAP based systems.  This is exactly how SAP is building the current HANA Accelerators, so it’s worth taking a little time to study how these are built and what development options within the ABAP environment support this scenario.

HANA as a Secondary Database

The scenario I’m describing is one that is quite common right now for HANA implementations.  You install HANA as a secondary database instead of a replacement for your current database.  You then use replication to move a copy of the data to the HANA system. Your ABAP applications can then be accelerated by reading data from the HANA copy instead of the local database. Throughout the rest of this blog I want to discuss the technical options for how you can perform that accelerated read.

Replication.png

ABAP Secondary Database Connection

ABAP has long had the ability to make a secondary database connection.  This allows ABAP programs to access a database system other than the local database. This secondary database connection can even be of a completely different DBMS vendor type. This functionality is extended to support SAP HANA for all the NetWeaver release levels from 7.00 and beyond. Service Note 1517236 (for SAP Internal) 1597627 (for everyone) lists the preconditions and technical steps for connection to HANA systems and should always be the master guide for these preconditions, however I will summarize the current state at the time of publication of this blog.

Preconditions

  • SAP HANA Client is installed on each ABAP Application Server. ABAP Application Server Operating System must support the HANA Client (check Platform Availability Matrix for supported operating systems).
  • SAP HANA DBSL is installed (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
    • Kernel 7.20 is already the kernel for NetWeaver 7.02, 7.03, 7.20, 7.30 and 7.31
    • Kernel 7.20 is backward compatible and can also be applied to NetWeaver 7.00, 7.01, 7.10, and 7.11
  • Your ABAP system must be Unicode or Single Code Page 1100 (Latin 1/ISO-8850-1) -See Service note 1700052 for non-Unicode Support instructions

Next, your ABAP system must be configured to connect to this alternative database. You have one central location where you maintain the database connection string, username and password.  Your applications then only need to specify the configuration key for the database making the connection information application independent.

This configuration can be done via table maintenance (Transaction SM30) for table DBCON. From the configuration screen you supply the DBMS type (HDB for HANA), the user name and password you want to use for all connections and the connection string. Be sure to include the port number for HANA systems. It should be 3<Instance Number>15. So if your HANA Database was instance 01, the port would be 30115.

DBCON.png

DBCON can also be maintained via transaction DBACOCKPIT. Ultimately you end up with the same entry information as DBCON, but you get a little more information (such as the default Schema) and you can test the connection information from here.

DBACOCKPIT.png

Secondary Database Connection Via Open SQL

The easiest solution for performing SQL operations from ABAP to your secondary database connection is to use the same Open SQL statements which ABAP developers are already familiar with. If you supply the additional syntax of CONNECTION (dbcon), you can force the Open SQL statement to be performed against the alternative database connection. 

For instance, let’s take a simple Select and perform it against our HANA database:

  SELECT * FROM sflight CONNECTION ('AB1')
    INTO TABLE lt_sflight
   WHERE carrid = 'LH'.

The advantage of this approach is in its simplicity.  With one minor addition to existing SQL Statements you can instead redirect your operation to HANA. The downside is that the table or view you are accessing must exist in the ABAP Data Dictionary. That isn’t a huge problem for this Accelerator scenario considering the data all resides in the local ABAP DBMS and gets replicated to HANA. In this situation we will always have local copies of the tables in the ABAP Data Dictionary.  This does mean that you can’t access HANA specific artifacts like Analytic Views or Database Procedures. You also couldn’t access any tables which use HANA as their own/primary persistence.

Secondary Database Connection Via Native SQL

ABAP also has the ability to utilize Native SQL. In this situation you write you database specific SQL statements.  This allows you to access tables and other artifacts which only exist in the underlying database.  There is also syntax in Native SQL to allow you to call Database Procedures.  If we take the example from above, we can rewrite it using Native SQL:

EXEC SQL.
    connect to 'AB1' as 'AB1'
  ENDEXEC.
  EXEC SQL.
    open dbcur for select * from sflight where mandt = :sy-mandt and carrid = 'LH'
  ENDEXEC.
  DO.
    EXEC SQL.
      fetch next dbcur into :ls_sflight
    ENDEXEC.
    IF sy-subrc NE 0.
      EXIT.
    ELSE.
      APPEND ls_sflight TO lt_sflight.
    ENDIF.
  ENDDO.
  EXEC SQL.
    close dbcur
  ENDEXEC.
  EXEC SQL.
    disconnect 'AB1'
  ENDEXEC.

Its certainly more code than the Open SQL option and a little less elegant because we are working with database cursors to bring back an array of data.  However the upside is access to features we wouldn’t have otherwise. For example I can insert data into a HANA table and use the HANA database sequence for the number range or built in database functions like now().

    EXEC SQL.
      insert into "REALREAL"."realreal.db/ORDER_HEADER"
       values("REALREAL"."realreal.db/ORDER_SEQ".NEXTVAL,
                   :lv_date,:lv_buyer,:lv_processor,:lv_amount,now() )
    ENDEXEC.
    EXEC SQL.
      insert into "REALREAL"."realreal.db/ORDER_ITEM" values((select max(ORDER_KEY)
        from "REALREAL"."realreal.db/ORDER_HEADER"),0,:lv_product,:lv_quantity,:lv_amount)
    ENDEXEC.

The other disadvantage to Native SQL via EXEC SQL is that there are little to no syntax checks on the SQL statements which you create. Errors aren’t caught until runtime and can lead to short dumps if the exceptions aren’t properly handled.  This makes testing absolutely essential.

Secondary Database Connection via Native SQL – ADBC

There is a third option that provides the benefits of the Native SQL connection via EXEC SQL, but also improves on some of the limitations.  This is the concept of ADBC – ABAP Database Connectivity.  Basically it is a series of classes (CL_SQL*) which simplify and abstract the EXEC SQL blocks. For example we could once again rewrite our SELECT * FROM SFLIGHT example:

****Create the SQL Connection and pass in the DBCON ID to state which Database Connection will be used
  DATA lr_sql TYPE REF TO cl_sql_statement.
  CREATE OBJECT lr_sql
    EXPORTING
      con_ref = cl_sql_connection=>get_connection( 'AB1' ).
****Execute a query, passing in the query string and receiving a result set object
  DATA lr_result TYPE REF TO cl_sql_result_set.
  lr_result = lr_sql->execute_query(
    |SELECT * FROM SFLIGHT WHERE MANDT = { sy-mandt } AND CARRID = 'LH'| ).
****All data (parameters in, results sets back) is done via data references
  DATA lr_sflight TYPE REF TO data.
  GET REFERENCE OF lt_sflight INTO lr_sflight.
****Get the result data set back into our ABAP internal table
  lr_result->set_param_table( lr_sflight ).
  lr_result->next_package( ).
  lr_result->close( ).

Here we at least remove the step-wise processing of the Database Cursor and instead read an entire package of data back into our internal table at once.  By default the initial package size will return all resulting records, but you can also specify any package size you wish thereby tuning processing for large return result sets.  Most importantly for HANA situations, however, is that ADBC also lets you access non-Data Dictionary artifacts including HANA Stored Procedures.  Given the advantages of ADBC over EXEC SQL, it is SAP’s recommendation that you always try to use the ADBC class based interfaces.

Closing

This is really just the beginning of what you could with this Accelerator approach to ABAP integration into SAP HANA. I’ve used very simplistic SQL statements in my examples on purpose so that I could instead focus on the details of how the technical integration works.  However, the real power comes when you execute more powerful statements (SELECT SUM … GROUP BY), access HANA specific artifacts (like OLAP Views upon OLTP tables), or database procedures.  These are all topics which I will explore more in future editions of this blog.

To report this post you need to login first.

171 Comments

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

  1. Firoz Ashraf

    Excellent Blog,

    In my scenario I want to connect to BW System instead of HANA. I have made the DBCON entry and the connection is also successful. However, when I run my simple code as suggested by you I am getting a short dump saying the table SFLIGHT is unknown or does not exists.

    SELECT * FROM sflight CONNECTION (‘SAP-BW-DEV’)

    INTO TABLE lt_sflight

    WHERE carrid = ‘LH’.

    DBCON.jpg

    What could be the reason for this dump?

    Regards,

    Firoz.

    (0) 
  2. Mr. Amit W

    Hi,

    Below query i wanted records filters on BUKRS, but unfortunately  am getting whole data from view.

    LV_SQL =  |SELECT MANDT, KTOPL, KSTAR, LTEXT, BUKRS | &&

                      |FROM _SYS_BIC.“dev.re.e10.cal.fi.tr/CV_COSTELEMENT_TEST” | &&

                     |(‘PLACEHOLDER’=(‘$$IP_BUKRS$$’,‘{ LV_BUKRS }’)) |

    (0) 
  3. jyotsna dm

    Hi Thomas,

    We have HANA as a secondary DB for ECC system. through DBCOCKPIT the connectivity is working fine.

    Do we have any other settings to perform FBL3H transaction code which is working on sidecar scenario i.e. HANA DB as secondary db.

    Regards,

    Jo

    (0) 
  4. Swetha Shivakumar

    Hi Thomas,

    Here you have explained how to access the HANA DB which is used as a secondary database through Native SQL/Open SQL/ADBC.

    In our solution while having HANA as a primary DB, we used to write the Stored procedures in HANA DB with the presentation layer as UI5 and access it via AMDP through Netweaver Gateway Odata services.

    My query is – can the AMDP be used to access the same HANA DB stored procedures if the HANA DB is a secondary database. The underlying primary DB is Oracle 10.2.0.5.0;

    If not then what would be appropriate method to call the stored procedures for a secondary HANA DB? Or should we use the proxies to access it for UI5?

    (0) 
    1. Thomas Jung Post author

      No AMDP is not possible with a secondary database connection.  To call a stored procedure from a secondary database connection you would have to use the techniques described in this blog for issuing Native SQL.  Or you could consider doing your service enablement within HANA directly using XSODATA services.

      (0) 
  5. Hugo Armstrong

    Hey Thomas,

    Nice blog, apparently implemented something like this but here is a question… there is a maximum_connections input which means that the limit if set to 0 then subsequently sets the maximum to 255.

    This seems like it would be an issue currently… not sure on why that is even a thing if secondary DB for HANA is a valid option. Definitely the connection works fine and can be conveniently / dynamically switched out with the ADBC classes otherwise…

    (0) 
    1. Thomas Jung Post author

      I don’t think the maximum_connections is anything to worry about. People often compare it to the number of users on their system and that’s incorrect.  There is a connection pool and connections are only used while actually communicating to the database. Therefore you can support a very high number of users with a much smaller number of maximum connections.

      (0) 
  6. Swetha Shivakumar

    If the options of using the HANA as a primary or secondary DB is ruled out by the customer, but still they want to use the UI5 as a front end and Netweaver Gateway as a web service, the usage of stored procedures and AMDP is ruled out. Will the usage of logical databases in the Netweaver gateway server as this might be a performance booster? If not what will be the ideal approach?

    (0) 
    1. Thomas Jung Post author

      Well your question really doesn’t have anything to do with this blog. If you just have a general question about logical databases in ABAP, I would post that in the ABAP forum.  However from my background I would say that I was never a fan of Logical Database. They generally decrease performance because they often must do a lot of unnecessary SQL to reach the lower objects in a hierarchy. If HANA is not an option, than just writing good, clean Open SQL in ABAP is probably the best performance option.

      (0) 
  7. Emin Ercelik

    Hi Thomas,

    Do you have any solution to use HANA connection on standard SQVI Abap SQL?

    We developed a custom data browser that running on HDB (ZSE16), the results are really perfect and imagine same benefit on sqvi..

    zse16 code is below šŸ™‚

    *&———————————————————————*

    *& Report  ZBC_DATA_BROWSER

    *&

    *&———————————————————————*

    *&

    *&

    *&———————————————————————*

    report  zbc_data_browser.

    set extended check off.

    type-pools: rsds.

    tables zbc_data_browser.

    data: begin of gt_htables occurs 1,

           table_name(30),

    end of gt_htables.

    data: gs_x030l  type x030l,

           gt_dfies  type table of dfies,

           gs_dfies  type dfies,

           gt_fdiff  type table of field_dif,

           gs_fdiff  type field_dif,

           gt_ftab   like table of rsdsfields with header line,

           gt_fcode  like table of rsdsfcode with header line,

           gt_events like table of rsdsevents with header line.

    data: gv_selid  type rsdynselselid,

           gt_tables type table of rsdstabs,

           gs_tables type rsdstabs,

    *      gt_fields type table of rsdsfields with header line,

           gt_expr   type rsds_texpr,

           gt_ranges type rsds_trange,

    *      gs_ranges type rsds_range,

           gt_where  type rsds_twhere,

           gs_where  type rsds_where,

           gv_active type i.

    data: gt_content type ref to data,

           gt_modif   type ref to data,

           gt_fcat    type lvc_t_fcat,

           gs_pfkey   type rsdspfkey.

    data: gv_fieldok,

           gv_dbcnt(30).

    field-symbols: <itab> type standard table,

                    <ntab> type standard table.

    define table_error.

       message e398(00) with ‘Table’ p_table &1.

    end-of-definition.

    *———————- parameters ————————*

    parameters: p_table type tabname obligatory                                 “table

                                      memory id dtb

                                      matchcode object dd_dbtb_16.

    parameters p_rows type i default 1000.                                      “rows

    selection-screen skip.

    parameters p_conn as checkbox default ‘X’.

    at selection-screen.

       if p_table ne gs_x030ltabname.

         if not p_conn is initial.

           if not zcl_hana_cnt_util=>con_name is initial.

             perform get_hana_tables.

             read table gt_htables with key table_name = p_table.

             if sysubrc ne 0.

               table_error ‘is not selectable for Hana DB’.

             endif.

           else.

             message e398(00) with ‘Hana connection is not active’.

           endif.

         else.

           clear zcl_hana_cnt_util=>con_name.

         endif.

         call function ‘DDIF_NAMETAB_GET’

           exporting

             tabname   = p_table

           importing

             x030l_wa  = gs_x030l

           tables

             dfies_tab = gt_dfies

           exceptions

             others    = 1.

         if gs_x030l is initial.

           table_error ‘does not exist or is not active’.

         elseif gs_x030ltabtype ne ‘T’

           and  gs_x030ltabtype ne ‘J’.

           table_error ‘is not selectable’.

         endif.

    *   Prepare free selection on table

         clear: gt_ftab[], gt_tables[], gt_ftab, gt_tables, gv_fieldok.

         select * from zbc_data_browser where tablename = p_table.

           gt_ftabtablename = zbc_data_browsertablename.

           gt_ftabfieldname = zbc_data_browserfieldname.

           append gt_ftabclear gt_ftab.

         endselect.

         if sysubrc eq 0gv_fieldok = ‘X’endif.

         loop at gt_dfies into gs_dfies

                         where keyflag = ‘X’

                           and fieldname ne ‘MANDT’

                           and fieldname ne ‘MANDANT’

                           and fieldname ne ‘CLIENT’

                           and rollname ne ‘MANDT’.

           gs_tablesprim_tab = p_table.

           append gs_tables to gt_tables.

           if gv_fieldok is initial.

             gt_ftabtablename = p_table.

             gt_ftabfieldname = gs_dfiesfieldname.

             append gt_ftab.

           endif.

         endloop.

         clear: gv_selid.

       endif.

    *————————- start of selection ————————-*

    start-of-selection.

       if gv_selid is initial.

    *   Init free selection dialog

         gt_eventsevent = ‘5’.

         gt_eventsprog = sycprog.

         gt_eventsform ‘NUMBER_OF_ENTRIES’.

         append gt_eventsclear gt_events.

         call function ‘FREE_SELECTIONS_INIT’

           exporting

             expressions  = gt_expr

           importing

             selection_id = gv_selid

             expressions  = gt_expr

           tables

             events       = gt_events[]

             tables_tab   = gt_tables

             fields_tab   = gt_ftab[]

           exceptions

             others       = 1.

       endif.

       gs_pfkeypfkey = ‘MAIN1’.

       gs_pfkeyprogram = sycprog.

       gt_fcodefcode = ‘NUMB’.

       gt_fcodeform = ‘NUMBER_OF_ENTRIES’.

       append gt_fcodeclear gt_fcode.

       call function ‘FREE_SELECTIONS_DIALOG’

         exporting

           selection_id            = gv_selid

           title                   = ‘Alan seçimleri’

           status                  = 1

           pfkey                   = gs_pfkey

         importing

           expressions             = gt_expr

           field_ranges            = gt_ranges

           number_of_active_fields = gv_active

         tables

           fields_tab              = gt_ftab[]

           fcode_tab               = gt_fcode[]

         exceptions

           internal_error          = 1

           no_action               = 1

           selid_not_found         = 1

           illegal_status          = 1.

       check sysubrc eq 0.

       perform list.

    *&———————————————————————*

    *&      Form  list

    *&———————————————————————*

    form list.

       delete from zbc_data_browser where tablename = p_table.

       loop at gt_ftab.

         zbc_data_browsertablename = gt_ftabtablename.

         zbc_data_browserfieldname = gt_ftabfieldname.

         modify zbc_data_browserclear zbc_data_browser.

       endloop.

       perform f_create_table using p_table.

       perform f_select_table.

       perform f_display_table.

    endform.                    “list

    *&———————————————————————*

    *&      Form  exit

    *&———————————————————————*

    form exit.

       exit.

    endform.                    “exit

    *———————————————————————*

    *       FORM f_create_table                                           *

    *———————————————————————*

    form f_create_table using p_tabname.

       field-symbols: <l_fcat> type lvc_s_fcat.

       call function ‘LVC_FIELDCATALOG_MERGE’

         exporting

           i_structure_name = p_tabname

         changing

           ct_fieldcat      = gt_fcat

         exceptions

           others           = 1.

       if sysubrc = 0.

    *   Complete field catalog

         loop at gt_fcat assigning <l_fcat>.

           <l_fcat>tabname = p_tabname.

         endloop.

         call function ‘LVC_FIELDCAT_COMPLETE’

           changing

             ct_fieldcat = gt_fcat

           exceptions

             others      = 1.

       else.

         write: ‘Error building field catalog’.

         stop.

       endif.

    * Create dynamic table for data

       call method cl_alv_table_create=>create_dynamic_table

         exporting

           it_fieldcatalog = gt_fcat

         importing

           ep_table        = gt_content.

       if sysubrc = 0.

         assign gt_content->* to <itab>.

       else.

         write: ‘Error creating internal table’.

         stop.

       endif.

    * Create dynamic table for modif

       call method cl_alv_table_create=>create_dynamic_table

         exporting

           it_fieldcatalog = gt_fcat

         importing

           ep_table        = gt_modif.

       if sysubrc = 0.

         assign gt_modif->* to <ntab>.

       else.

         write: ‘Error creating internal table’.

         stop.

       endif.

    endform.                    “f_create_table

    *———————————————————————*

    *       FORM f_select_table                                           *

    *———————————————————————*

    form f_select_table.

       if gv_active = 0.

         select * from (p_table)

                  into corresponding fields of table <itab>

                    up to p_rows rows

            connection (zcl_hana_cnt_util=>con_name).

       else.

    *   Selection with parameters

         clear gt_where.

         call function ‘FREE_SELECTIONS_RANGE_2_WHERE’

           exporting

             field_ranges  = gt_ranges

           importing

             where_clauses = gt_where.

         read table gt_where into gs_where with key tablename = p_table.

         select * from (p_table)

                  into corresponding fields of table <itab>

                    up to p_rows rows

            connection (zcl_hana_cnt_util=>con_name)

                 where (gs_wherewhere_tab).

       endif.

       write sydbcnt to gv_dbcnt.

       shift gv_dbcnt left deleting leading: ‘0’, space.

       concatenate ‘Records:’(001) gv_dbcnt

              into gv_dbcnt separated by space.

       concatenate sytitle gv_dbcnt

              into sytitle separated by ‘       ‘.

       if sydbcnt = 0.

         write: ‘No record selected’.

         stop.

       endif.

    endform.                    “f_select_table

    *&———————————————————————*

    *&      Form  number_of_entries

    *&———————————————————————*

    form number_of_entries tables pt_rsseldyn structure rsseldyn

                                   pt_rsdsfldnum structure rsdsfldnum

                             using p_fcode type rsdsfcodefcode. “#EC *

       data: ls_rsseldyn type rsseldyn,

             ls_ranges like line of gt_ranges,

             ls_frange like line of ls_rangesfrange_t,

             ls_selopt type rsdsselopt.

       clear: gt_ranges, gt_where, gs_where,

              gs_wherewhere_tab[], gv_active.

       loop at pt_rsseldyn into ls_rsseldyn.

         if ls_rsseldynsign ne space.

           ls_rangestablename = ls_rsseldyntablename.

           ls_frangefieldname = ls_rsseldynfieldname.

           ls_seloptsign = ls_rsseldynsign.

           ls_seloptoption = ls_rsseldynoption.

           ls_seloptlow = ls_rsseldynlow.

           ls_selopthigh = ls_rsseldynhigh.

           append ls_selopt to ls_frangeselopt_tclear ls_selopt.

           append ls_frange to ls_rangesfrange_tclear ls_frange.

           append ls_ranges to gt_rangesclear ls_ranges.

           add 1 to gv_active.

         endif.

       endloop.

       delete adjacent duplicates from gt_ranges comparing all fields.

       if gv_active = 0.

         select count(*) from (p_table)

           connection (zcl_hana_cnt_util=>con_name).

       else.

    *   Selection with parameters

         call function ‘FREE_SELECTIONS_RANGE_2_WHERE’

           exporting

             field_ranges  = gt_ranges

           importing

             where_clauses = gt_where.

         read table gt_where into gs_where with key tablename = p_table.

         select count(*) from (p_table)

           connection (zcl_hana_cnt_util=>con_name)

                where (gs_wherewhere_tab).

       endif.

       write sydbcnt to gv_dbcnt.

       shift gv_dbcnt left deleting leading: ‘0’, space.

       concatenate ‘Records:’(001) gv_dbcnt

              into gv_dbcnt separated by space.

       message gv_dbcnt type ‘I’.

       clear: pt_rsseldyn[], pt_rsdsfldnum[], p_fcode.

    endform.                    “number_of_entries

    *———————————————————————*

    *       FORM f_display_table                                          *

    *———————————————————————*

    form f_display_table.

       call function ‘REUSE_ALV_GRID_DISPLAY_LVC’

         exporting

           i_structure_name = p_table

         tables

           t_outtab         = <itab>

         exceptions

           program_error    = 1

           others           = 2.

    endform.                    “f_display_table

    *———————————————————————*

    *       FORM f_add_system                                             *

    *———————————————————————*

    form f_add_system using p_new type c.

       field-symbols: <l_irec> type any,

                      <l_upd>  type any.

       loop at gt_fdiff into gs_fdiff.

         read table gt_dfies into gs_dfies

                         with key fieldname = gs_fdifffieldname.

         loop at <ntab> assigning <l_irec>.

           assign component gs_fdifffieldname of structure <l_irec> to <l_upd>.

           if gs_dfiesdatatype = ‘CLNT’.

             <l_upd> = symandt.

           else.

             case gs_dfiesrollname.

               when ‘AENAM’.

                 <l_upd> = syuname.

               when ‘AEDAT’ or ‘LAEDA’.

                 <l_upd> = sydatum.

               when ‘AETIM’.

                 <l_upd> = syuzeit.

               when others.

             endcase.

           endif.

         endloop.

       endloop.

    endform.                    “f_add_system

    *&———————————————————————*

    *&      Form  GET_HANA_TABLES

    *&———————————————————————*

    form get_hana_tables .

       clear: gt_htables[], gt_htables.

       try.

           “open hana db connection

           exec sql.

             connect to :zcl_hana_cnt_util=>con_name

           endexec.

           if sysubrc <> 0.

             raise exception type cx_sy_native_sql_error.

           endif.

           “get hana db tables

           exec sql.

             open dbcur for

               select distinct table_name

                 from M_CS_TABLES

                where schema_name = :zcl_hana_cnt_util=>con_name

                  and table_name = :p_table

           endexec.

           do.

             exec sql.

               fetch next dbcur into :gt_htables

             endexec.

             if sysubrc ne 0.

               exit.

             else.

               append gt_htablesclear gt_htables.

             endif.

           enddo.

           exec sql.

             close dbcur

           endexec.

           “get hana db views

           exec sql.

             open dbcur for

               select distinct view_name

                 from VIEWS

                where schema_name = :zcl_hana_cnt_util=>con_name

                  and view_name = :p_table

           endexec.

           do.

             exec sql.

               fetch next dbcur into :gt_htables

             endexec.

             if sysubrc ne 0.

               exit.

             else.

               append gt_htablesclear gt_htables.

             endif.

           enddo.

           exec sql.

             close dbcur

           endexec.

           “close hana db connection

           exec sql.

             disconnect :zcl_hana_cnt_util=>con_name

           endexec.

         catch cx_sy_native_sql_error.

           message ‘SQL error’ type ‘I’.

       endtry.

    endform.                    ” GET_HANA_TABLES

    (0) 
  8. Shounak Mukherjee

    Hello All,

    We are using a HANA Sidecar setup. In HANA Studio I created a view joining FAGLFLEXA and BSEG with around 10 columns. I am able to preview data in the view.

    Within ECC I created a view with the same set of columns so that I can use OpenSQL. But when I am trying to query the view using OpenSQL , I am getting the following error:

    SQL error 258 when accessing table

    Error Text of the Database: “insufficient privilege: Not authorized:

    The schema has other views in it which is working fine. I believe some of the other tables and views that got replicated via the SLT had automatically granted the “select” rights on the schema.

    What am I missing here or some other approach is required. Do I need to execute the GRANT on the schema again after this view was created via the SYSTEM user?

    Thanks,

    Shounak

    (0) 
  9. Joachim Paulini

    Hi Thomas,

    very helpful blog post! However, a questions which remains to me is about the security of the network protocol underneath the DB connection in DBAcockpit. Can it be securely used to connect to a HANA database in the cloud? Do you know which protocol/DB query technology is used?

    Thanks a lot

    Joachim

    (0) 
  10. Raghavender Poosarla

    Hi Thomas,

                    I read in one of your comments about the Kernal switch pilot which was in progress then. Is it live now?

                   Can SQL be directed to secondary DB hana without any change in existing code?

    Regards,

    Raghav

    (0) 
  11. meenu agrawal

    Hi Thomas,

    Excellent blog.

    Thanks a lot for writing this.

    I am facing some issue .

    I am able to create a table in sec. data base from  ABAP using native sql. Also I am able to fetch data.

    But my methods to update data are not working (  example  Delete and insert).

    Also I am not getting any error in ABAP code , sy-subrc is always 0. still i can  not see my updates in HANA DB.

    What can be the reason ? DO we need any kind of commit statement or something?

    Regards,

    Meenu

    (0) 
  12. Marcio Aikawa

    Hi,

    I installed the SAP AS 7.5 trial and now, and DB System was installed also.

    To add the second connection (HANA Database) do I need to have this database (like Database in theĀ SAP Cloud Platform Cockpit) or if I click on the Add button the SAP AS will create a secondary HANA databaseĀ ?

    (0) 

Leave a Reply