Skip to Content

Dynamic usage - missing step...?

I have a component that I want to embed 1...n times within another component, inside Viewer Container UiElements. For a test, I'm just embedding one component, and hardcoding many values. But I can't get it to work - I don't get any errors, but I don't see any results on the screen.

The view is called VMAIN, the window WMAIN, the embedded component YEMBED. YEMBED is listed as a used component in both the view and the component controllers. YEMBED contains a text viewer element with fixed text.

The build usages method in the component controller looks like this:

   DATA usage TYPE wdapi_component_usage.

   usage-component_usage_name = |USAGE1|.

   usage-embedding_position = |VMAIN/VCU1|.

   usage-component_usage = wd_this->wd_cpuse_used_component(

           )->create_comp_usage_of_same_type( usage-component_usage_name ).

   usage-used_component = |YEMBED|.

   INSERT usage INTO TABLE wd_this->usages.

   wd_this->fire_prepare_navigation_evt( ).

The event "prepare_navigation_evt" is handled by a method in the view

  LOOP AT wd_comp_controller->usages INTO DATA(usage).

     wd_this->wd_get_api( )->prepare_dynamic_navigation(

         source_window_name = 'WMAIN'

         source_vusage_name = 'VMAIN_USAGE_1'

         source_plug_name = ''

         target_component_name = usage-used_component

         target_component_usage = usage-component_usage_name

         target_view_name = 'MAIN'

         target_plug_name = 'DEFAULT'

         target_embedding_position = usage-embedding_position ).

     IF usage-component_usage->has_active_component( ) IS INITIAL.

       usage-component_usage->create_component( ).



Finally, wdomodifyview looks like this:

   IF first_time EQ abap_true.

     DATA root TYPE REF TO cl_wd_transparent_container.

     root ?= view->get_element( |ROOTUIELEMENTCONTAINER| ).

     DATA(vcu) = cl_wd_view_container_uielement=>new_view_container_uielement(

                                                 id = |VCU1| view = view ).

     cl_wd_flow_data=>new_flow_data( vcu ).

     root->add_child( vcu ).


All help and tips gratefully received! I think I've included enough information, but if not, let me know.



Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 04, 2014 at 10:27 AM

    Hi Matthew,

    You just prepared the Navigation, but didn't fired! 

       After prepare_dynamic_navigation() method , Fire the Navigation Outbound plug.

    Or instead of prepare_dynamic_navigation( ), use do_dynamic_navigation( ) method.

    hope this helps,



    Add comment
    10|10000 characters needed characters exceeded