Entering content frame

This graphic is explained in the accompanying text Component Usage without Controller Access Locate the document in its SAP Library structure

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).

This graphic is explained in the accompanying text

 

To do this, choose Sample Usage®Foreign_Component. 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

...

       1.      Select a method of your controller that you are currently processing. This may be the predefined method WDDOINIT, for example, which is called automatically each time the controller is called. If the jump to the external component should not be connected to an event, you can select an event handler method instead.

       2.      Double-click on the method selected in step 1 to open an ABAP Editor, where you can insert the necessary method. The Web Dynpro Code Wizard provides support:

       3.      Click on the Web Dynpro Code Wizard  This graphic is explained in the accompanying text in the Editor’s toolbar. A list of the frequently used Web Dynpro statement structures are listed in a separate window.

       4.      Select Instantiate Used Component.

       5.      Display the F4 help for the Comp. usage line. All of the component usages that are available in the table of the Properties tab for the controller are displayed. Select the usage you require and confirm the dialog. The required source code is automatically inserted into the current method. Once you save the method, the external component is available to your own component at runtime.

This graphic is explained in the accompanying text 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.

This graphic is explained in the accompanying text

An example of how you set up a navigation is described in Part 5: Setting Up Navigation of the Creating a Simple Flight Info Application tutorial.

This graphic is explained in the accompanying text Every interface view of a used component can be embedded exactly once into a window of an outer component. If you want to embed a particular interface view of a component more than once in an outer window, you must first declare the respective number of component usages. Usually you do not know this number during design time, because it depends on factors that are determined only at runtime. For more information, refer to Dynamically Creating a Component Usage under Dynamic Programming in this documentation.

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.

 

 

Leaving content frame