Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Get CDS parameter names in ABAP program

former_member196892
Participant
0 Kudos
690

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

1 ACCEPTED SOLUTION

Föß
Active Participant
420

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 ).
2 REPLIES 2

Föß
Active Participant
421

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 ).

0 Kudos
420

Thank you Johann, exactly what I was looking for!