0

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!

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Christian Lendel
  • 410
  • 1
  • 4
  • 13
  • Are you able to create a MWE to reproduce the issue? With the snippets above, it's hard to check the system behavior. – vwegert May 20 '15 at 13:48
  • Can you tell me what a MWE is? Than I can check if it is possible – Christian Lendel May 20 '15 at 13:49
  • MWE = http://en.wikipedia.org/wiki/Minimal_Working_Example – vwegert May 20 '15 at 13:50
  • 1
    Try removing the exporting parameter on refresh_table_display method call.
    On another note you should not need to do the whole PAI business with ALV variant, let SAP delivered toolbar handle it for you. You should just be validating the variant from selection screen and passing it at time of PBO only. Rest system will take care of.
    – NewGuyInJava May 21 '15 at 14:20

1 Answers1

0

I finnaly figured out, what was wrong.

With Shift + double rightclick on a free area of the ALV within the program, you can see the error messages occured in the ALV. After fixing them, the functionality worked as it should.

My problem was this line:

wa_layout-stylefname = 'IMPUT_STYLE'.

Regards

Christian Lendel
  • 410
  • 1
  • 4
  • 13