2021 Jun 11 11:53 AM
Hello,
My task is to select from a CDS view that has parameters.
I have the values in a Key_tab with name/value. Is there a way to read the name of parameters of CDS so I can then pass the values?
I tried using RTTD class cl_abap_structdescr but the CDS input parameters are not included in the response.
DATA(lt_components) = CAST cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( 'C_CashFlowItem' ) )->components.
Any suggestions what I could use?
thanks in advance,
Lucian
2021 Jun 12 10:32 AM
Hi Lucian,
you can find the Parameters of a CDS View in table DD10B. You can also use the class cl_dd_sobject_factory. Maybe there are other possibilities, but I use this two solutions. Works for example in a ABAP 1909 system.
Short example:
DATA lr_handler TYPE REF TO cl_dd_ddl_handler.
DATA l_viewname TYPE viewname.
DATA l_entityname TYPE ddstrucobjname.
DATA lt_sobjnames TYPE if_dd_sobject_types=>ty_t_sobjnames.
DATA lr_sobject TYPE REF TO if_dd_sobject.
DATA lt_dd10bvtab TYPE dd10bvtab.
* get the entityname of the ddl
lr_handler ?= cl_dd_ddl_handler_factory=>create( ).
lr_handler->if_dd_ddl_handler~get_ddl_content_object_names(
EXPORTING
ddlname = 'ZFOE_A_MASS_CHANGE'
IMPORTING
entityname = l_entityname ).
APPEND l_entityname TO lt_sobjnames.
* get parameters tab
lr_sobject = cl_dd_sobject_factory=>create( ).
lr_sobject->read(
EXPORTING
get_state = 'M'
sobjnames = lt_sobjnames
IMPORTING
dd10bv_tab = lt_dd10bvtab ).
write: / lines( lt_dd10bvtab ).
2021 Jun 12 10:32 AM
Hi Lucian,
you can find the Parameters of a CDS View in table DD10B. You can also use the class cl_dd_sobject_factory. Maybe there are other possibilities, but I use this two solutions. Works for example in a ABAP 1909 system.
Short example:
DATA lr_handler TYPE REF TO cl_dd_ddl_handler.
DATA l_viewname TYPE viewname.
DATA l_entityname TYPE ddstrucobjname.
DATA lt_sobjnames TYPE if_dd_sobject_types=>ty_t_sobjnames.
DATA lr_sobject TYPE REF TO if_dd_sobject.
DATA lt_dd10bvtab TYPE dd10bvtab.
* get the entityname of the ddl
lr_handler ?= cl_dd_ddl_handler_factory=>create( ).
lr_handler->if_dd_ddl_handler~get_ddl_content_object_names(
EXPORTING
ddlname = 'ZFOE_A_MASS_CHANGE'
IMPORTING
entityname = l_entityname ).
APPEND l_entityname TO lt_sobjnames.
* get parameters tab
lr_sobject = cl_dd_sobject_factory=>create( ).
lr_sobject->read(
EXPORTING
get_state = 'M'
sobjnames = lt_sobjnames
IMPORTING
dd10bv_tab = lt_dd10bvtab ).
write: / lines( lt_dd10bvtab ).
2021 Jun 14 9:20 AM