cancel
Showing results for 
Search instead for 
Did you mean: 

fetching component_name of created component in component_usage

Former Member
0 Kudos

hello,

I got another problem too.

I make a single Component_Usage and create a component to this component_usage.

anzulegende_comp_usage =   wd_this->wd_cpuse_usage_z_itf_cid_a( ).
    IF anzulegende_comp_usage->has_active_component( ) IS INITIAL.
      anzulegende_comp_usage->create_component( COMPONENT_NAME = 'component_xyz' ).
      
    ENDIF.

but after this I can´t access the name of my created component 'component_xyz' via my component_usage.

If I use a component_usage_group I can access the component-names but this should be possible with a single component_usage too. or am I wrong?

the solution could be to use the structure-type "wdapi_component_usage" but I want to know if this is possible with a single component_usage too?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks Nithya I have tried your proposal now.

DATA: my_comp_usage_info type ref to if_wd_rr_component_usage,
      name_used_component type string.

my_comp_usage_info = WD_COMP_CONTROLLER->COMPONENT_USAGE_A->get_component_usage_info( ).
name_used_component = my_comp_usage_info->get_name( ).

but the method get_name is unfortunately only returning the name of the component_usage and not the name of the created component to this component_usage...

Former Member
0 Kudos

Hi Thorsten.

You can use the following trick.

l_ref_cmp_usage TYPE REF TO if_wd_component_usage,

lr_usage type ref to cl_wdr_component_usage,

lr_component type ref to if_wd_component.

when you have the reference to the usage in l_re_cmp_usage just cast it to cl_wdr_component_usage and call get_child_component.

l_ref_cmp_usage = wd_this->wd_cpuse_soptions( ).

IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

l_ref_cmp_usage->create_component( ).

ENDIF.

lr_usage ?= l_ref_cmp_usage.

lr_component = lr_usage->get_child_component( ).

Then you have the used component and can use the component info to get the name.

Cheers,

Sascha

Former Member
0 Kudos

thank you sascha again

I have chosen another way..I am working with the structure type WDAPI_COMPONENT_USAGE and there I have among other things the field "used_component".

greetz

Former Member
0 Kudos

it works and the trick was the downcast.

you obfuscated me with

l_ref_cmp_usage = wd_this->wd_cpuse_soptions( ).

but you mean

 component_usage = wd_this->wd_cpuse_<Name der Component-Usage>( ).

thanks again

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Thorsten,

Did you try the method get_component_usage_info( ) in if_wd_component_usage? It returns a reference of if_wd_rr_component_usage. You could call get_name on that object to get the component name. I havent tried it, but looks like that is the solution to your problem.

Hope this helps.

Regards

Nithya