cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically created components and ViewContainerUIElement

Former Member
0 Kudos

Dear Developers,

I am now facing this issue : how can I embbed a dynamically created component into

a ViewContainerUIElement?

I would need some relevant ABAP coding for this ( I have found some Java coding but I am looking for ABAP...).

Any idea?

Regards,

Olivier MATT

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Olivier.

you can use the interface IF_WD_NAVIGATION_SERVICES for this which is implemented by the view controller.

Check out the <a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/4c/60154219fce12ce10000000a1550b0/content.htm">help site</a>.

If you need more info just come back.

Cheers,

Sascha

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Oliver,

That's possible. Just let your component usage point to an interface. While creating an instance of a component for this component usage, dynamically specify the actual component to be used. Of course, the component needs to implement the component interface.

There's also the possibility to use ComponentUsageGroups, but this is a highly dynamic thing for which you will lose all workbench support. Hence, it's only advised to use it in very special cases.

It just means that you can add the interface view of the used component to your window at design time or define a context mapping at design time, etc. Everything needs to be done dynamically if ComponentUsageGroups were used.

hope this helps!

Cheers,

Darshna.

Former Member
0 Kudos

I forgot to mention that the component usage is defined with a component interface and not a real component (class).

Yashpal
Active Contributor
0 Kudos

Hi,

Message was edited by:

Yashpal Gupta

Former Member
0 Kudos

Hi Olivier.

I also create dynamic navigations to components via interface component usage.

Before each navigation I create the specialized component via this usage and then just create the outbound navigation. He3re is a code extract. I will comment some steps.



l_view_controller_api = wd_this->wd_get_api( ).

    lv_comp = Stru_Nav_Help-comp_name. #the name of the comp which implements the interface
    lv_plug = Stru_Nav_Help-plug. #name of the outbound plug for this navigation
    lr_usage = wd_comp_controller->get_component_usage( ). #returns the actual comp usage

    move stru_nav_help-auth to lv_auth. #is used as name for the outbound plug
    lv_outplug = wd_this->outbound_plugs->getvalue( lv_auth ). #hashtable that stores all dynamically created outbound plugs 

*   the navigation to the specified auth is performed
*   for the first time and have to be created.
    if lv_outplug is initial. # only if no outbound was previously created do the following
      lv_outplug = lv_auth.
      try.
          l_view_controller_api->PREPARE_DYNAMIC_NAVIGATION(
              source_window_name          = 'W_MAIN'
              source_vusage_name          = 'V_MAIN_USAGE_1'
              source_plug_name            = lv_outplug
              target_component_name       = lv_comp
              target_component_usage      = 'USED_COMPONENT'
              target_view_name            = 'W_MAIN'
              target_plug_name            = lv_plug
              target_embedding_position   = 'V_MAIN/UI_COMP_CONTAINER' ).

*         save outbound_plug for later usage.
          wd_this->outbound_plugs->setvalue(
           exporting
             name = lv_auth
             value = lv_outplug
          ).

        catch cx_wd_runtime_repository into lr_exception.
          data s type string.
          s = lr_exception->get_text( ).
          raise exception type cx_wdr_rt_exception.
      endtry.
    endif.

    lr_usage->create_component( lv_comp ). #Create the component to navigate to
 

*  fire the outbound plug
    l_view_controller_api->fire_plug(
     exporting
       plug_name = lv_outplug
     ).

Hope this helps a bit. For more questions feel free to post.

Cheers,

Sascha

Forgot to mention: I store the dynamically created outbound plugs cause if the same navigation should be triggered again later on and you would create a new outbound and fire the plug, the navigation would be performed twice (and so on), cause the framework stored them internally.

Message was edited by:

Sascha Dingeldey

Former Member
0 Kudos

Hi Sascha,

I am trying the coding you provided. I went to the SAP link too and I have read their coding.

What is this parameter : source_vusage_name ?

In my case, I have the following data in the WDDOINIT method of the view which contains the viewcontainerUIElement:

<ul>

<li>the source window of my component is MAINWINDOW

<li>the view which contains my viewcontainerUIElement is called TASKSELECTIONVIEW

<li>the viewcontainerUIElement is called VIEW_CONTAINER_UIELEMENT

<li>

<li>the component I want to use is implementing the ZIF_WD_SELECTIONIF

<li>the component (class) is ZWD_TASKSELECTIONCOMP

<li>the component is defined by USAGE_TASKSELECTION

</ul>

So now I tried the following coding:

L_VIEW_CONTROLLER_API = WD_THIS->WD_GET_API( ).

L_VIEW_CONTROLLER_API->PREPARE_DYNAMIC_NAVIGATION(
              source_window_name          = 'MAINWINDOW'
              source_vusage_name          = 'TASKSELECTIONVIEW'
              source_plug_name            = 'PLUGOUT'
              target_component_name       = 'ZWD_TASKSELECTIONCOMP'
              target_component_usage      = 'USAGE_TASKSELECTION'
              target_view_name            = 'SELECTIONVIEW'
              target_plug_name            = 'DEFAULT'
              target_embedding_position   = 'TASKSELECTIONVIEW/VIEW_CONTAINER_UIELEMENT' ).

I am not sure of the values I should pass as expected paramters. Do my coding seems ok? At least it returns me an :

The following error text was processed in the system DS4 : The ASSERT condition was violated.

The error occurred on the application server SERVER027_DS4_01 and in the work process 0 .

The termination type was: RABAX_STATE

The ABAP call stack was:

Method: PERFORM_NAVIGATION of program CL_WDR_CLIENT_APPLICATION=====CP

Method: NAVIGATE of program CL_WDR_CLIENT_APPLICATION=====CP

Method: DO_NAVIGATION of program CL_WDR_WINDOW_PHASE_MODEL=====CP

Method: PROCESS_REQUEST of program CL_WDR_WINDOW_PHASE_MODEL=====CP

Method: PROCESS_REQUEST of program CL_WDR_WINDOW=================CP

Method: EXECUTE of program CL_WDR_MAIN_TASK==============CP

Method: IF_HTTP_EXTENSION~HANDLE_REQUEST of program CL_WDR_MAIN_TASK==============CP

Method: EXECUTE_REQUEST_FROM_MEMORY of program CL_HTTP_SERVER================CP

Function: HTTP_DISPATCH_REQUEST of program SAPLHTTP_RUNTIME

Module: %_HTTP_START of program SAPMHTTP

PS: the component which is used here is already created in the WINDOWs WDDOINIT method.

Former Member
0 Kudos

Hi Olivier.

Source_vusage_name is the is the name of the 'view use'.

You find this by going to the window and clicking on the view

(TASKSELECTIONVIEW) which contains the view container for you component

usage. On the bottom you will see the properties.

Try using this value when calling prepare_dynamic_navigation. Let me know what

happened.

Cheers,

Sascha

Former Member
0 Kudos

Hi again Sascha,

I found that I had to use the source_vusage_name = 'TASKSELECTIONVIEW_USAGE_1'

So now... everything should be fine. But the error changed! I really wonder if I misunderstand WD4A or if its just complex to find out how to develop with it...

<b>The following error text was processed in the system DS4 : Controller SELECTIONVIEW Does Not Exist </b>

What the hell is going on?

Former Member
0 Kudos

he he he ...

ritie right ... sometimes you would pay million of dollars for a good SAP

documentation

so for the parameter target_view_name you have to use the name of the interface

view of the target component .. which is the name of the window that contains the

view you want to navigate to .. here it is hard to understand cause an interface

view is a window and not a view ?!?!

When you go to the target component in SE80 you see the folder 'Component

interface'. There is a sub folder 'interface views' which contains all windows of the

component.

Cheers,

Sascha

Former Member
0 Kudos

Thanks Sascha

Unfortunately I do not have million dollars to spend but at least you deserve points today. I am gonna give you some more now

It is working now. So wd4a was expecting a window name and not the view directly... all this terminology with wd4a is confusing.

By the way, which documentation did you use to learn this wd4a ?

Best regards,

Olivier MATT

Former Member
0 Kudos

Nice to hear that it is solved.

Well, when I started I did a lot of Trial and Error and asked a lot of questions here.

I also have the book of Ulli Hofmann (WebDynpro Abap) which is good for learning

the basic concepts. When you search SDN for threads and blogs you will often

find what you are looking for.

Anyway there are a lot of classes and methods in WD4A which does not seem to

be documented and you often just have to try to find oút if they fit your needs and

how the work.

Cheers,

Sasch