I am currently builiding an application based on ABAP WebDynpro. This application is generating component instances dynamically and then opening this componentn in a new tab using the tabstrip control.
Today I noticed that the ALV personalization was malfunctioning on all ALVs (SALV_WD_TABLE) used by the dynamically created component. I was able the create a new view, but once I restarted the application the drop-down list was always empty.
After some digging, I figured that the views where coming from the class CL_WDR_PERS_MANAGER. The views are stored in the table WDY_CONF_USER. When saving/loading the views a unique key is generated to identify the ALV control. By default this is done by the component usage path. For example, if you main component is called “WD_MAIN_CMP” and this has a component usage called “MAIN_ALV” of type SALV_WD_TABLE, a GUID will be generated from the string “WD_MAIN_CMP.MAIN_ALV”. This is how the P13n manager knows which settings are relevant for which control.
In my case the main component generates instances of another component and gives them a unique identifier (this is a must). The component path will then never be the same, hence the personalization manager will never find the same configuration again. I.e. the main component creates a component usage called “UNIQUE_0001” which then creates the ALV usage. This gives the path “WD_MAIN_CMP.UNIQUE_0001.MAIN_ALV”. Next time a component is created it will be given the name “UNIQUE_0002”, hence it will have the path “WD_MAIN_CMP.UNIQUE_0002.MAIN_ALV”. So although we are displaying the same ALV control, the P13n manager will not display any views created previously (unless you randomly generated the sam unique ID again).
The solution to this is to supply a configuration ID when you create the component:
DATA lrc_comp TYPE REF TO if_wd_component_usage.
DATA lwa_conf TYPE wdy_config_key.
* Setup ALV
lrc_comp = wd_this->wd_cpuse_main_alv( ).
IF lrc_comp->has_active_component( ) = abap_false.
* Create configuration ID using the component name, DYN_CMP
* is the name of the component which is created dynamically
lwa_conf-config_id = ‘WD_MAIN_CMP.DYN_CMP.MAIN_ALV’.
lwa_conf-config_type = cl_wdr_config_base=>c_config_type_gen.
lrc_comp->crete_component( configuration_id = lwa_conf ).
Thats it! Of course you can put any string you want as configuration ID, just make sure it is unique (if you re-use it somewhere else, views from both ALVs will be displayed in the drop-down).