Showing results for 
Search instead for 
Did you mean: 

Saving data from ABAP internal table to HANA CDS

0 Kudos

Hi, people !

I have a Report program that selects data from a Z table. After selecting the data, I do some calculations and adjustments to the data and insert it into an internal table. The data in this internal table must be recorded in a CDS table in Hana.The code below is a simple example, but the real code is taking too long to finish How to execute the same code without using a LOOP to write data to the HANA CDS.Could I use MODIFY (zcds_table) CLIENT SPECIFIED FROM TABLE p_itab ?
Report ZSAMPLE. 

DATA: vg_sql  type string,
      e_error type string.

LOOP AT it_ztable ASSIGNING FIELD-SYMBOL(<fs_ztable>).

   vg_sql = |INSERT INTO "ZSAMPLE"."data.logic.xscds::zcds_table" | &&
                | values( | &&
                          |'{ <fs_ztable>-id    }'| && |,| &&     " Id
                          |'{ <fs_ztable>-mandt }'| && |,| &&     " Mandt
                          |'{ <fs_ztable>-bukrs }'| && |,|      " bukrs
        CALL METHOD /tmf/cl_data_access=>execute_select_hana
            iv_sql    = vg_sql
            et_result = t_result.

      CATCH /tmf/cx_data_access INTO DATA(lx_exception).
          e_error = lx_exception->get_message( ).

    if e_error is initial.
      commit work

Accepted Solutions (1)

Accepted Solutions (1)

Active Contributor
0 Kudos

From my point of view it is not a good practice to insert data from an ABAP program into a HANA only managed table (except you are transporting the HANA artifacts via the ABAP layer too).

An option to improve the behavior would be to use an ABAP Managed Database Procedure, to which you pass the data of your internal table. Within the AMDP you can do an insert with a single INSERT command (please check the HANA SQL documentation for the INSERT command if you need more infos on that).

Answers (0)