on 09-04-2014 9:42 AM
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
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,
Regards,
Kiran
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But I have no outbound plug on my view. When I embed a component in a VCU statically, I don't require any plugs?
Making the change you suggested gave me an error that an outbound plug (presumably source_plug_name) is required. So I created an outbound plug, and fire it in after I've done the "prepare_dynamic_navigation".
I don't get any errors... but still nothing is display!
Hi Matthew,
We need an outbound plug with dynamic navigation! Please check this SAP help for reference: http://help.sap.com/saphelp_erp2005/helpdata/en/4c/60154219fce12ce10000000a1550b0/content.htm
I just modified your code. Please see the below code:
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 " Not required
target_view_name = usage-used_component | 'YEMBED' Interface View Name
target_plug_name = 'DEFAULT'
target_embedding_position = usage-embedding_position ).
ENDLOOP.
wd_this->fire_to_out_plg( ). " to_out is outbound plug of VMAIN
Or you can use do_dynamic_navigation( ) method.
LOOP AT wd_comp_controller->usages INTO DATA(usage).
wd_this->wd_get_api( )->do_dynamic_navigation(
source_window_name = 'WMAIN'
source_vusage_name = 'VMAIN_USAGE_1'
source_plug_name = 'TO_OUT' " Out bound plug name
target_component_name = usage-used_component
target_component_usage = usage-component_usage_name
target_view_name = usage-used_component | 'YEMBED' Interface View Name
target_plug_name = 'DEFAULT'
target_embedding_position = usage-embedding_position ).
ENDLOOP.
Please revert for further queries.
Regards,
Kiran
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.