Skip to Content

How to create CDS view dynamically without using Eclipse in SAP ABAP for HANA

Hi Gurus,

I am new to SAP ABAP for HANA.

I have a requirement about...

How to create CDS view dynamically without using Eclipse.

Could you please explain me in brief.

Please share me and waiting for your valuable information.😭

Regards,

Siva R

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Nov 06, 2015 at 08:03 AM

    Hi Siva,

    Using methods in class CL_DD_DDL_HANDLER, we can create and delete CDS Views from ABAP.

    Methods are like

    IF_DD_DDL_HANDLER~SAVE

    IF_DD_DDL_HANDLER~ACTIVATE

    IF_DD_DDL_HANDLER~DELETE

    Example:

    ls_ddddlsrcv-ddtext = 'Test CDS View'.

    ls_ddddlsrcv-ddlanguage = sy-langu.

    ls_ddddlsrcv-ddlname = lv_ddl_source

    ls_ddddlsrcv-source = <CDS view code>

    DATA(lref_dd_ddl_handler) = cl_dd_ddl_handler_factory=>create( ).

    TRY.

    CALL METHOD lref_dd_ddl_handler->save

    EXPORTING

    name = lv_ddl_source

    put_state = lv_putstate

    ddddlsrcv_wa = ls_ddddlsrcv

    * prid = -1

    .

    CATCH cx_dd_ddl_save .

    ENDTRY.

    TRY.

    CALL METHOD lref_dd_ddl_handler->activate

    EXPORTING

    name = lv_ddl_source

    * prid = -1

    .

    CATCH cx_dd_ddl_activate .

    ENDTRY.

    It will create both CDS entity and DDL SQL View in SE11.

    Thanks,

    Venkatesh

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 29, 2015 at 02:26 PM

    Dear Siva,

    ABAP CDS views can only be defined manually using The eclipse-based ABAP Development Tools.

    http://scn.sap.com/community/abap/eclipse/blog/2014/02/04/new-data-modeling-features-in-abap-for-hana

    Kind regards,

    Carine

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 05, 2015 at 01:31 PM

    Hi,

    what is your use case ?

    If you are aiming solely at the DB-views (which are created from the CDS-Views) and your coding only needs to run on HANA then using ADBC might be an option.

    If you have a CDS-view serving as a template this approach might look like:

    NEW cl_sql_statement( )->execute_query( |select definition from views where view_name = 'ddic_name_of_template_cds_view'| ).

    NEW cl_sql_statement( )->execute_ddl( |modified SQL-create-view command just retrieved| ).

    Add comment
    10|10000 characters needed characters exceeded