on 05-21-2010 8:55 AM
Hi,
I have a component A which use a component B.
Is it possible to get the component usage name in the component B?
I found it in the component B by debugging, but I found no method to get it.
The problem is that I can't pass it manually through component B, because I need the name in the wddoinit of component B.
I can export the name to memory before i add the component usage and import it in the wddoinit of B, but I would not prefer.
Any ideas?
Thanks
Florian
Hi,
Whenever you declare any component usage in your comp controller, a constant is created ( but hidden to you ) in using component.
You can access component usage reference by constant:
wd_this->wd_cpuse_<Your Comp Usage Name Declared By You>
ex
wd_this->wd_cpuse_MY_ALV ( here MY_ALV is my comp usage name )
and component usage interface can be accessed by
wd_this->wd_cpifc_<Your Comp Usage Name Declared By You>
wd_this->wd_cpifc_MY_ALV.
Or if you want to fetch you component usage name programmaticaly ( like MY_ALV in my example above )
then check this code snippet
DATA: lo_cmp_usage TYPE ref to if_wd_component_usage.
DATA: lv_cmp_name type string.
lo_cmp_usage = wd_this->wd_cpuse_MY_ALV( ).
lv_cmp_name = lo_cmp_usage->NAME.
Hope this helps.
Regards
Manas Dua
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
the problem is that i do not declare the component usage on design time.
I add it dynamically on the wddoinit of component A, so I can't use both options..
I do it like this:
create component usage group
l_cmp_api = wd_this->wd_get_api( ).
if l_cmp_api->has_cmp_usage_group( 'TEST_GROUP' ) is initial.
wd_this->cmp_usage_group = l_cmp_api->create_cmp_usage_group(
name = 'TEST_GROUP'
used_component = 'ZWD_DYNAMIC_CI' ).
endif.
add component usages to group
data: lo_cmp_usage TYPE REF TO IF_WD_COMPONENT_USAGE.
lo_cmp_usage = wd_this->cmp_usage_group->add_component_usage(
name = 'USAGE1'
embedding_position = 'MAIN_VIEW/VC1'
used_component = 'ZWD_SEARCH_REPORT1' ).
I tried the following to get the component usage and call a method to set the name. But I get an error that ZWD_DYNAMIC_CI is
a component interface and so it cant create a instance. This component interface has only a interface fiew. I need this interface to make the component exchangeable. I'm new on web dynpro so I don't know if I do this correct.
DATA lo_ic TYPE REF TO object .
data: lo_ic2 TYPE REF ZIWCI_WD_SEARCH_REPORT1.
lo_ic = lo_cmp_usage->GET_INTERFACE_CONTROLLER( ).
lo_ic2 ?= lo_ic.
lo_ic2->set_usage_name( 'USAGE1' ).
I even can't execute the following code instead of the code above:
IF lo_cmp_usage->has_active_component( ) is INITIAL.
lo_cmp_usage->create_component( ).
ENDIF.
I get the same error!!
Regards Florian
Edited by: Florian Halder on May 21, 2010 12:36 PM
Hi,
I think I solved my problem. I use the same assistance class for both components with an attribute gv_usage_name.
After I add the component usage I have to create the component with the following code.
WD_ASSIST->gv_usage_name = 'USAGE1'.
IF lo_cmp_usage->has_active_component( ) is INITIAL.
lo_cmp_usage->create_component( component_name = 'ZWD_SEARCH_REPORT1'
assistance_class = wd_assist ).
ENDIF.
On the wddoinit of the other component i read the attribute
lv_usage_name1 = wd_assist->gv_usage_name.
Unfortunatelly I can't pass the value directly through the other component by a method, because therefor I have to create the component first. But I need the value in the wddoinit method.
Regards Florian
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.