Show TOC

Background documentationDEMO_COMMON_ASSISTANCE1 Locate this document in the navigation structure

 

This demo application uses a very simple example to illustrate how the instance of an assistance class can be used by two different components. A prerequisite is that the assistance classes of both components must both have the same name.

  • Initially, both demo components, DEMO_COMMON_ASSISTANCE1 and 2, access the assistance class CL_WD_DEMO_COMM_ASSI.

  • The component DEMO_COMMON_ASSISTANCE1 uses DEMO_COMMON_ASSISTANCE2 as a subcomponent.

  • The method WDDOINIT of the component controller of DEMO_COMMON_ASSISTANCE1 uses the method l_ref_cmp_usage->create_component to instantiate the used component. To ensure that both components access the same instance of the assistance class, the reference to the current instance of the assistance class of the main component must be passed as the value for the parameter ASSISTANCE_CLASS.

    Syntax Syntax

    1. method WDDOINIT .
    2. data: l_ref_cmp_usage type ref to if_wd_component_usage.
    3. l_ref_cmp_usage =   wd_this->wd_cpuse_sub_component( ).
    4. if l_ref_cmp_usage->has_active_component( ) is initial.
    5. l_ref_cmp_usage->create_component( ASSISTANCE_CLASS= wd_assist ).
    6. endif.
    7. endmethod.
    End of the source code.

An instance is created for the used component and the existing instance of the assistance class (belonging to the main component) is assigned to the instance of the used component. If you pass the name of the assistance class instead of the reference variable wd_assist here, you would create a second, independent, instance of the same class.

Note Note

More information is available in Programming Manual for Web Dynpro ABAP

End of the note.