Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Dynamic component usage of select options

Hi all,

I know, dynamic component usage as been discussed several times here, but it seems that I am not smart enough, to understand it.

Maybe somebody can help me.

During runtime, I generate a tabstrip with a various number of tabs.

Each tab should contain a select_option component.

In WDDOINIT of the View I implemented the following:

      
      DATA lo_componentcontroller TYPE REF TO ig_componentcontroller .
      lo_componentcontroller =   wd_this->get_componentcontroller_ctr( ).

      lo_componentcontroller->define_compusages_so( ).

      lo_componentcontroller->add_compusages_so(
          p_embpos    = lv_selopt_emb_pos    " string
          p_usagename = lv_selopt_node_name  " string
          p_used_comp = 'WDR_SELECT_OPTIONS' " string
        ).

LV_SELOPT_EMB_POS contains "V1.SEL_OPT1"

LV_SELOPT_NODE_NAME contains "SEL_OPT1"

The container SEL_OPT1 is getting created dynamically on View V1 in WDDOMODIFYVIEW.

In WDDOMODIFYVIEW of the View is this:

Create the

      DATA: lt_range_table  TYPE REF TO data,
            rt_range_table  TYPE REF TO data,
            read_only       TYPE abap_bool,
            typename        TYPE string,
            l_ref_cmp_usage TYPE REF TO if_wd_component_usage,
            L_VIEW_CONTROLLER_API type ref to IF_WD_VIEW_CONTROLLER.

      sel_opt_uielem = cl_wd_view_container_uielement=>new_view_container_uielement(
        id      = lv_elem_id
        visible = CL_WD_VIEW_CONTAINER_UIELEMENT=>E_VISIBLE-VISIBLE
      ).

      .......
      Embed it into the tab and so on
      .......

      cl_wd_matrix_head_data=>new_matrix_head_data( element = sel_opt_uielem ).
      lr_form_cont->add_child( sel_opt_uielem ).

      ......

      l_ref_cmp_usage = WD_COMP_CONTROLLER->CMP_USAGE_GROUP->get_component_usage(
                                                  name = lv_elem_id ).

      IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
        l_ref_cmp_usage->create_component( ).
      ENDIF.

      L_VIEW_CONTROLLER_API = WD_THIS->WD_GET_API( ).
      try.
        L_VIEW_CONTROLLER_API->PREPARE_DYNAMIC_NAVIGATION(
              source_window_name          = 'WD_SEL_OPT'        "Name of the Window
              source_vusage_name          = 'V1_USAGE_1'
              source_plug_name            = ''
              target_component_name       = 'WDR_SELECT_OPTIONS'
              target_component_usage      = l_ref_cmp_usage->NAME
              target_view_name            = 'SELECTION_SCREEN'
              target_plug_name            = 'DEFAULT'
              target_embedding_position   = lv_elem_embedd ).
         catch cx_wd_runtime_repository.
          raise exception type cx_wdr_rt_exception.
      endtry.

      L_INTF_CONTROLLER ?= l_ref_cmp_usage->GET_INTERFACE_CONTROLLER( ).
      wd_this->m_handle = L_INTF_CONTROLLER->init_selection_screen( ).

      lt_range_table =
        wd_this->m_handle->create_range_table(
              i_typename = 'S_CARRID' ).
*
      wd_this->m_handle->add_selection_field(
          i_id = 'S_CARR_ID'
          it_result = lt_range_table
          i_read_only = read_only ).

lv_elem_embedd contains V1/SEL_OPT1.

Currently I just try to add S_CARR_ID for testing of course I need to do this more than one time in a loop.

The coding doesn´t throw any error or exeption, but the selectoption is not getting displayed ! Any other dynamically created element is displayed as expected.

Does anybody have an Idea, where my mistake is ?

Any help would be appreciated.

Best regards, Matthias

Former Member
Not what you were looking for? View more on this topic or Ask a question