cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically load a Component Usage into a UIViewElement

Former Member
0 Kudos

I've gone through quite a good number of posts surrounding this topic, but I am unable to get a straight answer to my problem. Currently, I have a SAP Delivered WD which I do NOT want to modify or enhance. The only access I have to this WD is through the SAP delivered BADI for the WDMODIFYVIEW.

Within this single hook method I have to be able to achieve quite a bit. I'm confident I can do all I need unless being able to dynamically create a usage to another WD component and embed it into a (dynamically created) UIViewElement on the screen. From what I've read, you can ONLY create component usages at design time either explicitly or through generic WD Interfaces. Both of these approaches require an enhancement or modification to the SAP delivered web dynpro.

Am I correct here? Is there NO WAY to dynamically add a usage at runtime within, and only within, the WDMODIFY hook method?

I truly hope this all makes sense. If so, kindly point me in the right direction!

AF

Edited by: Andrew.Fletcher on Oct 29, 2010 4:12 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

ChrisPaine
Active Contributor
0 Kudos

Hello,

Absolutely you can have dynamic component usages - how do you think that the FPM works otherwise

Have a look at component FPM_GAF_COMPONENT and in particular the view CNR_VIEW and the method PREPARE_NAVIGATION and in the assistance class - method NAVIGATE.

It seems to come down to something very similar to what you have tried - but it works Although it is fired from an event in the component controller rather than in the WDDOMODIFYVIEW.. Given the error message you are getting - I'd suggest that you'd pretty much stuck with needing to find another place to actually trigger the view navigation

Chris

Former Member
0 Kudos

Hi Chris,

Thanks for your reply. Really hopeful this is possible (somehow), else there's no way for me to meet my requirements.

How about this alternative. Within WDDOMODIFY, is it possible to create another View in the parent WD Component and create elements within that view. Once that view is constructed, I could embed that view in a UI container within the initial View that is calling the WDDOMODIFY?

Whacky, I know... but this is the requirement! Or, again, is it to late to do all this logic in the WDDOMODIFY?

Thanks!

Andy

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

As the error suggest, navigation isn't possible in WDDOMODIFYVIEW becuase that event handler comes too late in the Phase Model. I wonder, however, why you are reluctant to simply use the Enhancement Framework and add a post-exit to one of the methods that is better timed to the phase model for what you want to acomplish.

Former Member
0 Kudos

For reference, here is the code I'm using to try to achieve this madness. When I run this, I get a runtime error:

The following error text was processed in the system CH6 : Navigation in Phase WDDOMODIFYVIEW Cannot Be Triggered. Component:

This pretty much tells me I'm dead in the water, what I'm trying to do is impossible. Just need to make sure before I follow alternate routes!

******************************

  • Get necessary context &

  • controller instances

******************************

DATA cl_view TYPE REF TO cl_wdr_view.

DATA cl_view_context TYPE REF TO cl_wdr_context_node.

DATA cl_view_controller TYPE REF TO cl_wdr_controller.

DATA cl_componentcontroller TYPE REF TO cl_wdr_component.

cl_view ?= view.

cl_view_context ?= wd_context.

cl_view_controller ?= cl_view_context->controller.

cl_componentcontroller ?= cl_view_controller->component.

data interf_outbound_plug type WDY_RR_IOBOUND_PLUG.

CALL METHOD cl_view->view_info->create_outbound_plug

EXPORTING

plug_name = 'TO_VW_CONTENT'

  • repository_handle_id =

receiving

outbound_plug = interf_outbound_plug

.

*TRY.

DATA: lr_usage_group TYPE REF TO if_wd_component_usage_group.

DATA: lr_component TYPE REF TO if_wd_component.

DATA: lr_usage TYPE REF TO if_wd_component_usage.

DATA: cl_lr_usage TYPE REF TO cl_wdr_component_usage.

"lr_component = wd_comp_controller->wd_get_api( ).

lr_usage_group = cl_componentcontroller->if_wd_component~create_cmp_usage_group(

name = 'acme_interf_USAGES'

used_component = 'Z_acme_interf' ).

lr_usage = lr_usage_group->add_component_usage( 'acme_interf_USAGE' ).

lr_usage->create_component( 'Z_acme_interf' ).

"lr_usage->delete_all_navigation_targets( plug_name = 'TO_VW_CONTENT' ).

DATA repository_handle TYPE REF TO if_wd_repository_handle.

CALL METHOD cl_view->if_wd_navigation_services_new~prepare_dynamic_navigation

EXPORTING

source_window_name = 'source_window_T'

source_vusage_name = 'source_USAGE_5'

source_plug_name = 'TO_VW_CONTENT'

target_component_name = 'Z_acme_interf'

target_component_usage = 'acme_interf_USAGE'

target_view_name = 'MAIN'

target_plug_name = 'DEFAULT'

target_embedding_position = 'source/Zinterf2'

  • plug_parameters =

RECEIVING

repository_handle = repository_handle

.

  • CATCH cx_wd_runtime_repository .

*ENDTRY.

"cl_view->fire_to_mainview_plg( ).

cl_view->fire_plug(

exporting

plug_name = 'TO_VW_CONTENT'

).

DATA cl_interface_controller TYPE REF TO IF_WD_CONTROLLER.

cl_lr_usage ?= lr_usage.

cl_interface_controller = cl_lr_usage->child_component->controller.

data interf_int type ref to ZIWCI__acme_interf.

data o_interf_int type ref to object.

CALL METHOD lr_usage->get_interface_controller

receiving

if_controller = o_interf_int

.

interf_int ?= o_interf_int.

  • Call ny interface methods if needed

Edited by: Andrew.Fletcher on Oct 29, 2010 4:13 AM

Edited by: Andrew.Fletcher on Oct 29, 2010 4:14 AM

Edited by: Andrew.Fletcher on Oct 29, 2010 5:32 AM