
You can use an external component in two ways: If you only want to display the external component, but not change the data of its interface controller or use its functions, you can omit the explicit usage declaration of the external interface controller in the current controller. In this case, simply declare the usage of the external component in the currently edited controller (see figure).
To do this, choose . This merely enters the usage of the component in the table, and you can call the component for display purposes from the current component.
The usage was added to the metadata again.
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:
Procedure
Example: For a component, the usage of another component has been declared. This usage is called MY_COMP_USAGE.
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.Method WD_CPUSE_<MY_COMPONENT_USAGE>
This method contains the local interface of each controller as soon as you have declared the usage of an external component for (the entire component at first and then for) the current controller. The method returns a reference variable of type IF_WD_COMPONENT_USAGE. (See also Predefined Methods of the Local Controller Interface in Part 1 of the programming manual).
In the first step, method WD_CPUSE_<MY_COMP_USAGE was used to generate an object for the used component. In the second step, the object was instantiated provided that no instance existed.
You can now access the used component, but you cannot use the methods of its interface controller, because you need to declare an additional usage for the respective controllers (see Component-Usage with Controller Access).
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 one's 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.
An example of setting up navigation is described in Part 5: Setting Up Navigation of tutorial Creating a Simple Flight Information Application.
If you also want to access the content of the external controller context, or if you want to use methods of this controller, see Component Usage with Controller Access.