Skip to Content
0
May 13, 2020 at 05:20 PM

Saving data from ABAP internal table to HANA CDS

432 Views

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
                       ')'.
    TRY.
        CALL METHOD /tmf/cl_data_access=>execute_select_hana
          EXPORTING
            iv_sql    = vg_sql
          IMPORTING
            et_result = t_result.

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

    if e_error is initial.
      commit work
    endif.
ENDLOOP.