Skip to Content
avatar image
Former Member

ALV changing variants doesn´t apply filter

Hi all,

I have a problem with my own program. In this program the user has to enter data on the selection screen. There he can also choose one of the saved ALV variants. In the next step an ALV list will be shown with the selected data. Additionally the data in the ALV should have the chosen layout. In this ALV the user has the possibility to change, save, choose and manage the variants of the ALV with the normal ALV functionality. Nevertheless there is a problem with that. If the user wants to switch to an existing ALV variant with a filter, it sometimes (90% of all cases) doesn´t apply the filters and the sorting of the chosen ALV. If he enters this variant in the selection screen, the right ALV layout with all filters, sorting etc. will be applied correctly.


My code for the f4-help in the selection screen:


DATA: lwa_variant LIKE disvariant,
lw_exit_flag TYPE cmpflag.

lwa_variant-report = sy-repid.


CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
EXPORTING
is_variant = lwa_variant
i_save = 'A'
IMPORTING
e_exit = lw_exit_flag
es_variant = wa_variant
EXCEPTIONS
not_found = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE s899(mm) WITH text-088.
ELSEIF NOT lw_exit_flag IS INITIAL.
MESSAGE s899(mm) WITH text-089.
CLEAR wa_variant.
ENDIF.
p_layou = wa_variant-variant.



My code in the PBO of the screen with the ALV:


DATA: i_fieldcat TYPE lvc_t_fcat,
wa_layout TYPE lvc_s_layo,
wa_stable TYPE lvc_s_stbl,
wa_r_variant TYPE DISVARIANT.

IF o_alv_container IS INITIAL.

CREATE OBJECT o_alv_container
EXPORTING
container_name = 'O_ALV_CONTAINER'.

CREATE OBJECT o_alv
EXPORTING
i_parent = o_alv_container
EXCEPTIONS
others = 1.
IF sy-subrc <> 0.
MESSAGE e002.
ENDIF.
IF wa_variant IS INITIAL AND p_layou IS INITIAL.
wa_r_variant-report = sy-repid.
ELSEIF wa_variant IS NOT INITIAL.
wa_r_variant = wa_variant.
wa_r_variant-handle = SPACE.
wa_r_variant-log_group = SPACE.
wa_r_variant-username = SPACE.
wa_r_variant-text = SPACE.
wa_r_variant-dependvars = SPACE.
ELSE.
wa_r_variant-report = sy-repid.
wa_r_variant-variant = p_layou.

ENDIF.

wa_layout-zebra = ''.
wa_layout-stylefname = 'IMPUT_STYLE'.
wa_layout-sel_mode = 'A'.
wa_layout-cwidth_opt = 'X'.

CALL METHOD o_alv->set_table_for_first_display
EXPORTING
is_variant = wa_r_variant
is_layout = wa_layout
i_save = 'A'
i_default = 'A'
CHANGING
it_outtab = i_alv_data
it_fieldcatalog = i_fieldcat
EXCEPTIONS
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE e002.
ENDIF.


ELSE.

wa_stable-COL = 'X'.
wa_stable-row = 'X'.

CALL METHOD o_alv->refresh_table_display
EXPORTING
is_stable = wa_stable
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE e003.
ENDIF.
ENDIF.


I never had such a problem with any other programs and I never heard about this. Unfortunality there a many field in the tables (>20) so the users have to configure it the way they want to have it (with filters, sorting etc.). After hours of testing I wasn´t able to figure out what´s wrong with my code. I also debugged the SAP ALV methods. I found out that in some cases the system wasn´t able to load the filters. But I don´t know why. Any tips or information can be useful for me.


Thanks in advance!

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    May 21, 2015 at 11:21 AM

    Did you

    • Perform The Consistency Check
    • Reset the global ALV buffers (report BALVBUFDEL)
    • Check the stored variant are up to date

    Regards,

    Raymond

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Raymond,

      your 1st guess (Perform Consistency Check) helped. I didn´t know this functionality. I figured out that there were some errors in my layout and fieldcat. After fixing them everything works fine.

      Thank you very much for the great help. Finally, after hours of testing and debugging, it works.

      Best regards,

      Christian

  • May 20, 2015 at 08:59 PM

    It could be the buffering issue. Try passing the I_BYPASSING_BUFFER = 'X' in the method SET_TABLE_FOR_FIRST_DISPLAY.

    Regards,
    Naimesh Patel

    Add comment
    10|10000 characters needed characters exceeded