Skip to Content
0
Sep 04, 2014 at 08:42 AM

Dynamic usage - missing step...?

39 Views

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

ENDIF.

ENDLOOP.


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

ENDIF.


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


thanks


matt