<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574140#M2008825</link>
    <description>&lt;P&gt; &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Have. Sy-repid and username already set in. But it has no effect when passed to go_grid-&amp;gt;set_table_for_first_display or go_grid-&amp;gt;refresh_table_display&lt;/P&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;   *_ Variant&lt;BR /&gt;gs_variant-report = sy-repid.&lt;BR /&gt;gs_variant-username = sy-uname.&lt;BR /&gt;&lt;BR /&gt;PERFORM f_select_variant.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD go_grid-&amp;gt;set_table_for_first_display&lt;BR /&gt;EXPORTING&lt;BR /&gt;is_variant = gs_variant&lt;BR /&gt;i_save = 'A'&lt;BR /&gt;is_layout = gs_layout&lt;BR /&gt;it_toolbar_excluding = gt_exclude&lt;BR /&gt;CHANGING&lt;BR /&gt;it_outtab = gt_print&lt;BR /&gt;it_fieldcatalog = gt_fieldcatalog
it_sort              = gt_sort.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;</description>
    <pubDate>Wed, 25 May 2022 01:47:28 GMT</pubDate>
    <dc:creator>siongchao_ng</dc:creator>
    <dc:date>2022-05-25T01:47:28Z</dc:date>
    <item>
      <title>Layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574138#M2008823</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2053598-selection-screen-layout.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Hi my ALV layout variant settings are lost once there is whether there is_stable or omit out is_stable, there is no difference.&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;CALL METHOD go_grid-&amp;gt;set_frontend_fieldcatalog&lt;BR /&gt;    EXPORTING&lt;BR /&gt;      it_fieldcatalog = lt_fieldcatalog.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  CALL METHOD go_grid-&amp;gt;set_frontend_layout&lt;BR /&gt;    EXPORTING&lt;BR /&gt;      is_layout = gs_layout.&lt;BR /&gt;  CALL METHOD go_grid-&amp;gt;set_variant&lt;BR /&gt;    EXPORTING&lt;BR /&gt;      is_variant = gx_variant&lt;BR /&gt;      i_save     = 'A'.&lt;BR /&gt;

*_ Call refresh once after updated catalog before manipulating&lt;BR /&gt;*  project totals data&lt;BR /&gt;    CALL METHOD go_grid-&amp;gt;refresh_table_display&lt;BR /&gt;      EXPORTING&lt;BR /&gt;        is_stable      = lwa_stbl &lt;BR /&gt;        i_soft_refresh = 'X'.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 May 2022 07:49:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574138#M2008823</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2022-05-24T07:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574139#M2008824</link>
      <description>&lt;P&gt;It's probably gs_variant as it seems you defined the program name nowhere (nor the ALV name).&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 11:55:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574139#M2008824</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-05-24T11:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574140#M2008825</link>
      <description>&lt;P&gt; &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Have. Sy-repid and username already set in. But it has no effect when passed to go_grid-&amp;gt;set_table_for_first_display or go_grid-&amp;gt;refresh_table_display&lt;/P&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE&gt;   *_ Variant&lt;BR /&gt;gs_variant-report = sy-repid.&lt;BR /&gt;gs_variant-username = sy-uname.&lt;BR /&gt;&lt;BR /&gt;PERFORM f_select_variant.&lt;BR /&gt;&lt;BR /&gt;CALL METHOD go_grid-&amp;gt;set_table_for_first_display&lt;BR /&gt;EXPORTING&lt;BR /&gt;is_variant = gs_variant&lt;BR /&gt;i_save = 'A'&lt;BR /&gt;is_layout = gs_layout&lt;BR /&gt;it_toolbar_excluding = gt_exclude&lt;BR /&gt;CHANGING&lt;BR /&gt;it_outtab = gt_print&lt;BR /&gt;it_fieldcatalog = gt_fieldcatalog
it_sort              = gt_sort.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 25 May 2022 01:47:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574140#M2008825</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2022-05-25T01:47:28Z</dc:date>
    </item>
    <item>
      <title>Re: Layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574141#M2008826</link>
      <description>&lt;P&gt;OK. Why do you overcomplexify by calling the field catalog, sort and filter criteria methods instead of only passing the parameter IS_VARIANT of set_table_for_first_display?&lt;/P&gt;&lt;P&gt;Note that this is very common requirement, and you have examples all over the place, even in SAP demo programs.&lt;/P&gt;</description>
      <pubDate>Wed, 25 May 2022 05:55:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574141#M2008826</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-05-25T05:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: Layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574142#M2008827</link>
      <description>&lt;P&gt;  &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Yup it is common if it is just remained that. Only passing the parameter IS_VARIANT of set_table_for_first_display can actually works. Found the issue causing it but no idea to show the variant settings because the causing variant problem subroutine f_change_display_mode is required by the program.&lt;/P&gt;&lt;P&gt;Apparently after calling this go_grid-&amp;gt;set_table_for_first_display there is a f_change_display mode subroutine. As shown below the contents of f_change_display_mode. So the issue is the layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;PERFORM f_change_display_mode.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;FORM f_change_display_mode .&lt;BR /&gt;&lt;BR /&gt;  DATA: lt_fieldcatalog   TYPE lvc_t_fcat,&lt;BR /&gt;        lwa_fieldcatalog  TYPE lvc_s_fcat.&lt;BR /&gt;&lt;BR /&gt;  FIELD-SYMBOLS &amp;lt;fs_fieldcatalog&amp;gt; TYPE lvc_s_fcat.&lt;BR /&gt;&lt;BR /&gt;*_ If ALV object not initialized&lt;BR /&gt;  IF go_grid IS INITIAL.&lt;BR /&gt;    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'&lt;BR /&gt;      IMPORTING&lt;BR /&gt;        e_grid = go_grid.&lt;BR /&gt;  ENDIF.&lt;BR /&gt;&lt;BR /&gt;*_ Always copy and adjust from pre-build catalog to avoid seq error&lt;BR /&gt;  lt_fieldcatalog = gt_fieldcatalog.&lt;BR /&gt;&lt;BR /&gt;  LOOP AT lt_fieldcatalog ASSIGNING &amp;lt;fs_fieldcatalog&amp;gt;&lt;BR /&gt;    WHERE fieldname = 'FY_TOTAL'&lt;BR /&gt;       OR fieldname = 'WLP01'&lt;BR /&gt;       OR fieldname = 'WLP02'&lt;BR /&gt;       OR fieldname = 'WLP03'&lt;BR /&gt;       OR fieldname = 'WLP04'&lt;BR /&gt;       OR fieldname = 'WLP05'&lt;BR /&gt;       OR fieldname = 'WLP06'&lt;BR /&gt;       OR fieldname = 'WLP07'&lt;BR /&gt;       OR fieldname = 'WLP08'&lt;BR /&gt;       OR fieldname = 'WLP09'&lt;BR /&gt;       OR fieldname = 'WLP10'&lt;BR /&gt;       OR fieldname = 'WLP11'&lt;BR /&gt;       OR fieldname = 'WLP12'.&lt;BR /&gt;&lt;BR /&gt;    IF gv_ok_code = 'DISP_MONTH'.&lt;BR /&gt;&lt;BR /&gt;      IF &amp;lt;fs_fieldcatalog&amp;gt;-fieldname = 'FY_TOTAL'.&lt;BR /&gt;        &amp;lt;fs_fieldcatalog&amp;gt;-no_out = gc_x.&lt;BR /&gt;      ELSE.&lt;BR /&gt;        &amp;lt;fs_fieldcatalog&amp;gt;-no_out = space.&lt;BR /&gt;      ENDIF.&lt;BR /&gt;&lt;BR /&gt;    ELSEIF gv_ok_code = 'DISP_YEAR'.&lt;BR /&gt;&lt;BR /&gt;      IF &amp;lt;fs_fieldcatalog&amp;gt;-fieldname = 'FY_TOTAL'.&lt;BR /&gt;        &amp;lt;fs_fieldcatalog&amp;gt;-no_out = space.&lt;BR /&gt;      ELSE.&lt;BR /&gt;        &amp;lt;fs_fieldcatalog&amp;gt;-no_out = gc_x.&lt;BR /&gt;      ENDIF.&lt;BR /&gt;&lt;BR /&gt;    ENDIF.&lt;BR /&gt;  ENDLOOP.&lt;BR /&gt;&lt;BR /&gt;*_ If subtotal/total function set disabled, remove the func from catalog&lt;BR /&gt;  IF gv_mode_disptotal = space.&lt;BR /&gt;    lwa_fieldcatalog-do_sum = space.&lt;BR /&gt;    MODIFY lt_fieldcatalog FROM lwa_fieldcatalog&lt;BR /&gt;                   TRANSPORTING do_sum&lt;BR /&gt;                          WHERE do_sum &amp;lt;&amp;gt; ''.&lt;BR /&gt;  ENDIF.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;  CALL METHOD go_grid-&amp;gt;set_frontend_fieldcatalog&lt;BR /&gt;    EXPORTING&lt;BR /&gt;      it_fieldcatalog = lt_fieldcatalog.&lt;BR /&gt;&lt;BR /&gt;  IF gv_total_disabled = gc_x.&lt;BR /&gt;*_ Always call this function to disable total/subtotal function&lt;BR /&gt;    PERFORM f_change_display_func USING space.&lt;BR /&gt;&lt;BR /&gt;  ELSE.&lt;BR /&gt;&lt;BR /&gt;*_ Call refresh once after updated catalog before manipulating&lt;BR /&gt;*  project totals data&lt;BR /&gt;    CALL METHOD go_grid-&amp;gt;refresh_table_display&lt;BR /&gt;      EXPORTING&lt;BR /&gt;        i_soft_refresh = 'X'.&lt;BR /&gt;&lt;BR /&gt;    IF gv_mode_disptotal = gc_x.&lt;BR /&gt;*_ If subtotal/total function set enabled, manually toggle the func&lt;BR /&gt;*  in order to generate value set otherwise it'll be missing in another&lt;BR /&gt;*  display view mode (month/year)&lt;BR /&gt;      PERFORM f_change_display_func USING space.&lt;BR /&gt;      PERFORM f_change_display_func USING 'X'.&lt;BR /&gt;    ELSE.&lt;BR /&gt;*_ Call func to manipulate project totals data&lt;BR /&gt;      PERFORM f_update_alv_total.&lt;BR /&gt;    ENDIF.&lt;BR /&gt;&lt;BR /&gt;  ENDIF. "_ Total/Subtotal function disabled&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2022 07:14:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574142#M2008827</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2022-05-27T07:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574143#M2008828</link>
      <description>&lt;P&gt;I don't have any issue with this minimal reproducible code (press SAVE to refresh).&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TABLES sscrfields.
DATA go_alv TYPE REF TO cl_gui_alv_grid.
DATA gt_sflight TYPE TABLE OF sflight.

PARAMETERS p_varian TYPE disvariant-variant.

SELECTION-SCREEN BEGIN OF SCREEN 1001.
PARAMETERS dummy.
SELECTION-SCREEN END OF SCREEN 1001.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_varian.
  DATA(fcat) = VALUE lvc_t_fcat( ).
  DATA(varian) = VALUE disvariant( report = sy-repid username = sy-uname ).
  CALL FUNCTION 'LVC_VARIANT_SELECT'
    EXPORTING
      i_user_specific     = 'X'
      it_default_fieldcat = fcat
    CHANGING
      cs_variant          = varian
    EXCEPTIONS
      OTHERS              = 0.
  p_varian = varian-variant.

AT SELECTION-SCREEN OUTPUT.
  CASE sy-dynnr.
    WHEN 1001.
      IF go_alv IS INITIAL.
        CREATE OBJECT go_alv
          EXPORTING
            i_parent = cl_gui_container=&amp;gt;screen0.
        SELECT * FROM sflight INTO TABLE gt_sflight.
        go_alv-&amp;gt;set_table_for_first_display(
            EXPORTING i_structure_name = 'SFLIGHT'
                      i_save = 'A'
                      is_variant = VALUE #( report = sy-repid username = sy-uname variant = p_varian )
            CHANGING it_outtab = gt_sflight ).
      ENDIF.
  ENDCASE.

AT SELECTION-SCREEN.
  CASE sy-dynnr.
    WHEN 1000.
      IF sscrfields-ucomm = 'ONLI'.
        CALL SELECTION-SCREEN 1001.
      ENDIF.
    WHEN 1001.
      IF sscrfields-ucomm = 'SPOS'.
        go_alv-&amp;gt;refresh_table_display( i_soft_refresh = 'X' ).
      ENDIF.
  ENDCASE.
  sscrfields-ucomm = ''.

AT SELECTION-SCREEN ON EXIT-COMMAND.
  CASE sy-dynnr.
    WHEN 1001.
      go_alv-&amp;gt;free( ).
      FREE go_alv.
  ENDCASE.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 May 2022 08:05:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574143#M2008828</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-05-27T08:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: Layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574144#M2008829</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Found the source of the problem in the program that is causing the selected ALV layout variant got lost when displaying the output. Right before calling the go_grid-&amp;gt;refresh_table_display, program is calling go_grid-&amp;gt;get_frontend_fieldcatalog and this importing current fieldcatalog is overwriting the selected alv layout variant from the selection screen. I commented out this and populate the lt_fieldcatalog with the selected alv variant from the selection screen gt_fieldcatalog and the problem is fixed.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA lt_fieldcatalog TYPE lvc_t_fcat.

  FIELD-SYMBOLS &amp;lt;fs_fieldcatalog&amp;gt; TYPE lvc_s_fcat.

  DATA  :        lwa_stbl type lvc_s_stbl.    "ins 
*  ** Row,Col Stable
  lwa_stbl-row = 'X'.
  lwa_stbl-col = 'X'.

  REFRESH gt_fcode.



*_ If ALV object not initialized
  IF go_grid IS INITIAL.
    CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
      IMPORTING
        e_grid = go_grid.
  ENDIF.

* start del 
**_ Import current fieldcatalog from displayed ALV
*  CALL METHOD go_grid-&amp;gt;get_frontend_fieldcatalog
*    IMPORTING
*      et_fieldcatalog = lt_fieldcatalog.
* end del 

*  start ins 
*  *_ Always copy and adjust from pre-build catalog to avoid seq error
  lt_fieldcatalog = gt_fieldcatalog.
*  end ins 

  LOOP AT lt_fieldcatalog ASSIGNING &amp;lt;fs_fieldcatalog&amp;gt;
    WHERE fieldname = 'BUDGET_AWARDED'
       OR fieldname = 'PFY_TOTAL'
       OR fieldname = 'FY_TOTAL'
*      begin ins 
       OR fieldname = 'LAST_SUBM_TOTAL'
       OR fieldname = 'CURR_SUBM_TOTAL'
*      end ins 
       OR fieldname = 'WLP01'
       OR fieldname = 'WLP02'
       OR fieldname = 'WLP03'
       OR fieldname = 'WLP04'
       OR fieldname = 'WLP05'
       OR fieldname = 'WLP06'
       OR fieldname = 'WLP07'
       OR fieldname = 'WLP08'
       OR fieldname = 'WLP09'
       OR fieldname = 'WLP10'
       OR fieldname = 'WLP11'
       OR fieldname = 'WLP12'
       OR fieldname = 'TOTAL_ITD'
       OR fieldname = 'BUDGET_BALANCE'.

    IF pv_show_total = gc_x.
      &amp;lt;fs_fieldcatalog&amp;gt;-do_sum = gc_a.
    ELSE.
      &amp;lt;fs_fieldcatalog&amp;gt;-do_sum = space.
    ENDIF.
  ENDLOOP.


  CALL METHOD go_grid-&amp;gt;set_frontend_fieldcatalog
    EXPORTING
      it_fieldcatalog = lt_fieldcatalog.

*  * begin ins 
  CALL METHOD go_grid-&amp;gt;set_frontend_layout
    EXPORTING
      is_layout = gs_layout.
  CALL METHOD go_grid-&amp;gt;set_variant
    EXPORTING
      is_variant = gx_variant
      i_save     = 'A'.
* end ins  

*_ Call refresh once after updated catalog before manipulating
*  project totals data
  CALL METHOD go_grid-&amp;gt;refresh_table_display
    EXPORTING
      is_stable      = lwa_stbl "ins  
      i_soft_refresh = 'X'.

  PERFORM f_update_alv_total.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 May 2022 01:26:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574144#M2008829</guid>
      <dc:creator>siongchao_ng</dc:creator>
      <dc:date>2022-05-31T01:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Layout variant settings are lost while using method refresh_table_display of class cl_gui_alv_grid</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574145#M2008830</link>
      <description>&lt;P&gt;Good to know, thanks for the feedback.&lt;/P&gt;&lt;P&gt;Don't forget to explain the context right in your question (that you have a button to change the layout after the ALV is displayed), otherwise people can't understand why you need to do all this stuff for displaying an ALV with given variant. A minimal reproducible example is welcome too.&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 06:23:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/layout-variant-settings-are-lost-while-using-method-refresh-table-display/m-p/12574145#M2008830</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-05-31T06:23:35Z</dc:date>
    </item>
  </channel>
</rss>

