cancel
Showing results for 
Search instead for 
Did you mean: 

Delete dynamic created component usages

Former Member
0 Kudos

Hi,

I have static component usage of type Comp. Interface Z_REVISION_CI and create component usages of Z_REVISION dynamically via IF_WD_COMPONENT_USAGE->CREATE_COMP_USAGE_OF_SAME_TYPE( ).

After a while, I want to delete this component usages  and use IF_WD_COMPONENT_USAGE->DELETE_COMPONENT( ). If I re-create a component usage with the previously used name, I get an error "Component Usage REVISION_123 Already Exists" altough the component usage with this name was deleted firstly.

Are the component usage names saved internally in web dynpro?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Instead of using the method IF_WD_COMPONENT_USAGE=>CREATE_COMP_USAGE_OF_SAME_TYPE( ), I use now the component usage returned by IF_WD_VIEW_CONTROLLER->DO_DYNAMIC_NAVIGATION( ) and I can re-use my usage names!

The problem was that the SAP documentation tolds me, that I need to use CREATE_COMP_USAGE_OF_SAME_TYPE( ) of a static usage  for dynamic component usage creation, but it seems to work without! Documentation: http://help.sap.com/saphelp_erp60_sp/helpdata/en/bc/191a427ff6db2ce10000000a1550b0/content.htm

Former Member
0 Kudos

Hi,

try with the following code..It may work

lo_cmp_usage =   wd_this->wd_cpuse_activity( ).

IF lo_cmp_usage->has_active_component( ) IS INITIAL.

   lo_cmp_usage->create_component( ).

ELSE.

      lo_cmp_usage->delete_component( ).

       lo_cmp_usage->create_component( ).

ENDIF.

former_member211591
Contributor
0 Kudos

Hi Christian,

You can check while recreating if your component usage has an active component or not.

If yes, delete and create, else create.

if lo_cmp_usage->has_active_component( ) is not initial.
     lo_cmp_usage->delete_component( ).
endif.
lo_cmp_usage->create_component( ).

BR

ismail

Former Member
0 Kudos

I've already done this, but I can not create another component usage with the same name although the first one is deleted via this method!

For example, check out the Web Dynpro Component WDR_TEST_DYNAMIC and create a usage with the name "TEST", then delete it and re-create it (you must set the cehckbox "Embed Component . It will raise an error.

former_member211591
Contributor
0 Kudos

Do you want to create a new component usage or a new component of your component usage?

I think your getting things mixed.

IMHO delete_component() deletes the component of your usage, not the usage itself. Thus you can't create a second usage with the same name.

Check this out:

You've got one component usage for your interface component (I'm referring to your previous question.) and you want to dynamically change the displayed component.

"Dynamically create name of the component which you want to create: (This component has to implement your component interface)

concatenate 'Z' <somestring>  into lv_comp_name.

"Load your dynamic component for your interface usage:

   lo_cmp_usage =   wd_this->wd_cpuse_dok_comp_intf( ).  "Get component usage of your interface component
   if lo_cmp_usage->has_active_component( ) is initial.
     lo_cmp_usage->create_component( COMPONENT_NAME = lv_comp_name ). "Loading the dynamic component for the component usage
   endif.