cancel
Showing results for 
Search instead for 
Did you mean: 

Inter component dynamic method invocation.

Former Member
0 Kudos

Hi All,

I have a requirement where I need to invoke a method of one of the components from another method in another component dynamically at runtime. the challenge in this requirement is that the name of the component of whose method is to be called will also be known at runtime itself, so it makes me unable to create a component usage during development and need to find an alternative for the same to be taken care at runtime.

Please suggest and help, kind of in a desperate situation.

Thanks and Regards,

Abhishek.

Accepted Solutions (0)

Answers (1)

Answers (1)

amy_king
Active Contributor
0 Kudos

Hi Abhishek,

Would something like the following work for your scenario? You would need first to declare all possible component usages in the properties tab.

CASE condition.

    WHEN use_component_one.

        lo_cmp_usage_componentone = wd_this->wd_cpuse_componentone( ).

        IF lo_cmp_usage_
componentone->has_active_component( ) IS INITIAL.
            lo_cmp_usage_
componentone->create_component( ).
        ENDIF.

        lo_
componentone = wd_this->wd_cpifc_componentone( ).
        lo_
componentone->some_method( ).

    WHEN use_component_two.

        lo_cmp_usage_componenttwo = wd_this->wd_cpuse_componenttwo( ).

        IF lo_cmp_usage_
componenttwo->has_active_component( ) IS INITIAL.
            lo_cmp_usage_
componenttwo->create_component( ).
        ENDIF.

        lo_
componenttwo = wd_this->wd_cpifc_componenttwo( ).
        lo_
componenttwo->some_other_method( ).

ENDCASE.

Cheers,

Amy