cancel
Showing results for 
Search instead for 
Did you mean: 

webdynpro alv view variant saved and programatically used

former_member193460
Contributor
0 Kudos


Hi Experts,

     i have created a webdynpro application with ALV and saved certain views (in admin mode). I want to utilize these views programatically (set or remove view variants).

Please share a sample code.

Thanks & Regards,

Tashi

Accepted Solutions (1)

Accepted Solutions (1)

ramakrishnappa
Active Contributor
0 Kudos

Hi Tashi,

Please refer the below link

Selection Variables in ALV view variants

Hope this helps you.

Regards,

Rama

former_member193460
Contributor
0 Kudos

i found out my self, Please see a sample code below:

data lo_pers_manager   type ref to if_wd_personalization.

data lcl_variants TYPE WDR_PERS_VARIANTS.

data lcl_config_key TYPE WDY_CONFIG_KEY.

DATA lo_INTERFACECONTROLLER TYPE REF TO IWCI_SALV_WD_TABLE .
FIELD-SYMBOLs: <fs_variant> TYPE WDR_PERS_VARIANT.

*Get alv API

lo_api_controller = lo_INTERFACECONTROLLER->wd_get_api( ).

* get personalization manager

lo_pers_manager = lo_api_controller->get_personalization_manager( ).

CALL METHOD lo_pers_manager->GET_VARIANTS
  RECEIVING
    VARIANTS           = lcl_variants
    .

READ TABLE lcl_variants ASSIGNING <fs_variant> INDEX 3.

lcl_config_key-config_id = <fs_variant>-config_id.
lcl_config_key-config_type = <fs_variant>-config_type.
lcl_config_key-config_var = <fs_variant>-config_var.

CALL METHOD lo_pers_manager->SET_DEFAULT_VARIANT
EXPORTING
CONFIG_KEY = lcl_config_key
scope = 4.

it worked fine

Former Member
0 Kudos

Hi Tashi!

I have a problem with that. My code works correctly in Customizing-Mode but unfortunately it doesn´t work correctly with regular mode. Why have I this problem? How could I solve that?

Thanks,

Sergio.

former_member193460
Contributor
0 Kudos

Hi Sergio,

     Please elaborate more.

Regards,

tashi

Former Member
0 Kudos

Hi Tashi,

I have created two Variants for a View in my ALV. I have created them in Customizing-Mode (&sap-config-mode=x) in my Floor Plan Manager (FPM). I have used your  previous code to select a variant and all works without any error or syntax mistake. If I try to use that it doesn´t work correctly. The point is that when I am in Customizing-Mode in my FPM it works correctly. The code is the same fot both cases but in a mode it works and in the other it doesn´t work.

When it doesn´t work, it always set the [Standardview] by default, sometimes with the fields of the correct variant and sometimes with all fiels of the structure that I have used in this ALV.

[StandarView]                              ***********THIS IS MY CURRENT RESULT***************

Col1|Col2|Col3|Col4|Col5|Col6

The result must be a View Variant with some fields that I have customized previously in Customizing-Mode and that I have transported with the correct Customization transport-task.

MyViewVariant                ***********ONLY WORKS IN CUSTOMIZING-MODE***************

Col1 |Col4|Col6

How could I solve that to get always the correct view-variant?

Regards,

Sergio.

former_member193460
Contributor
0 Kudos

Hi Sergio,

     i am not sure what is the issue, but you can just check if you have set any other view as "initial view" ..The view selected in the code will be displayed only when you dont have any "initial view" selected from the UI.

The code which i have pasted above is for stand alone webdynpro application and it worked fine for me.

Thanks & Regards,

Tashi

Former Member
0 Kudos

Hi Sergio,

were you able to make it work?

Thanks,

Antonio

Answers (0)