cancel
Showing results for 
Search instead for 
Did you mean: 

Functionality of create_component of if_wd_component_usage

former_member450736
Active Participant
0 Kudos

Hi,

i have following web dynpro comps/interfaces: comp1, comp2 which are implementing intf1 and Main component which has usage of intf1.

intf1 has method display, interface view zview, and context mycontext( with attribute attr (string ) ).

in component 1 method display is assigning text 'Comp1' to attr which is bound to textview of view 'MAIN' of this component1 and interface view ZVIEW is the default window for this component component1

in component 2 method display is assigning text 'Comp2' to attr which is bound to textview of view 'MAIN' of this component2 and interface view ZVIEW is the default window for this component component2

in both of the above components component1 and component2 in their respective wddoinit methods i am calling display method of respective component so that textviews of these components contain respective texts 'Comp1' and 'Comp2'

in Main componet i have two buttons component1 and component2 in view MAIN and viewcontainerUI element where i have embedded interface view zview for which i have usage in this component and finally in event handlers of two buttons i am creating respective components using interface that is common between those two components.

intitally i am instantiating the component 1 in wddoint of main component the text "Comp1" displayed now in the main component when i execute however when i click any button "component1" and "component2" respective components are instantiated using create_component however i dont see the respective texts "comp1" and "comp2" from component1 and component2.

My questions here is if i create compoent using compoent Usage does it call the wddoinit method of that Used component?? as i am expecting the corresponding texts to be displayed whenever i click these buttons in main component

Please suggest if am missing anything here ( though my questions is very big one, i hope this is very trivial scenario )

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi, kranthi kumar.

I guess, when you want to create the component usage, you used the following code:


"when Create ZTEST_IF_COMP1 which impletemented the IFuFF1A ZTEST_IF
* asure that usage of component ZTEST_IF_COMP1 has been created
  DATA: lr_cmp_usage TYPE REF TO if_wd_component_usage.

  lr_cmp_usage = wd_this->wd_cpuse_if_usage( ).    "IF_usage is the Interface's usage
  IF lr_cmp_usage->has_active_component( ) IS INITIAL.
    lr_cmp_usage->create_component( 'ZTEST_IF_COMP1' ).
  ENDIF.

"when Create ZTEST_IF_COMP2 which impletemented the IFuFF1A ZTEST_IF
* asure that usage of component ZTEST_IF_COMP1 has been created
  DATA: lr_cmp_usage TYPE REF TO if_wd_component_usage.

  lr_cmp_usage = wd_this->wd_cpuse_if_usage( ).
  IF lr_cmp_usage->has_active_component( ) IS INITIAL.
    lr_cmp_usage->create_component( 'ZTEST_IF_COMP2' ).
  ENDIF.

So, in my eyes, it will be created only one time.

About your requirement, my project encountered many times. The problem is not at "WDDOINIT", but your "Navigation" or "Plug"...

In our solution, we use the interface method,or interface event. All are very easy..

For example, you can use Outbound Plug of the custom component, and inbound plug of the different component which implemented the WD component Interface.But the first thing you should do is add the Inbound Plug when you create the Interface View in the WD component Interface.

For example, you can have one reference:


method ONACTIONEMBEDED_COMP1 .

* asure that usage of component COMP_D1 has been created
  DATA: lr_cmp_usage TYPE REF TO if_wd_component_usage.

  lr_cmp_usage = wd_this->wd_cpuse_if_usage( ).
  IF lr_cmp_usage->has_active_component( ) IS INITIAL.
    lr_cmp_usage->create_component( 'ZTEST_IF_COMP1' ).
  ENDIF.

* disable the Component 2 related button
  wd_this->enable_buttons( iv_enable = abap_false   im_type = 'COMP1'  ).

* call the Interface Method, at the same time in this method Trriger the Interface Event(Inside sub component)
  wd_this->call_if_method( ).

* fire the Outbound Plug
  wd_this->navigate_to_if_view( ). 

endmethod.

I don't know whether it is fit for your requirement or not..Hope it can...

Best wishes.

former_member450736
Active Participant
0 Kudos

Hi Can Tang,

you are correct here:

* call the Interface Method, at the same time in this method Trriger the Interface Event(Inside sub component)
  wd_this->call_if_method( ).
 
* fire the Outbound Plug
  wd_this->navigate_to_if_view( ).

to navigate to interface view which is implemented in comp1 or comp2 we should use navigation from main component to one of these components as it is mentioned in SAP docu

Calling the Used Component

To display the external component, you can now embed an interface view of any window of this component in a window of your current component. This procedure corresponds exactly to embedding a view of oneu2019s own component. By setting up navigation from one outbound plug of a view of your current component to an inbound plug of the interface view of a window of the external component, you enable the external component to be displayed.

and also i can say in order to populate interface context we can either use events or interface controller methods, i am clear.

However i still don't understand what is the importance of create_component as displaying the view is taken care by navigation mechanism and populating context is done by interface controller methods, which means the instantiated component usage reference will not used any

where explicitly except for to check it has active component or not

method MY_CONTROLLER_METHOD .
data:     L_REF_CMP_USAGE      type ref to      IF_WD_COMPONENT_USAGE. 
L_REF_CMP_USAGE =   WD_THIS->WD_CPUSE_MY_COMP_USAGE( ). 
if  L_REF_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) is initial.
L_REF_CMP_USAGE->CREATE_COMPONENT( ).
 endif.
endmethod.

however from SAP docu i can see it is must to instantiate the component to use it

Instantiating the Used Component

Regardless of whether you decided on a component usage with or without controller access, you now have to instantiate the used component in a method that you have selected:

Edited by: kranthi kumar on Oct 18, 2010 3:32 PM