Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Keep Default Layout of ALV

Former Member
0 Kudos

I changed layout of ALV, then pressed button "Enter" but not "Save". But when I entered the screen again, the layout was changed to the setting which I changed last time, not default setting.

Source code is shown below.

     DATA lt_acc_bal_fcat TYPE lvc_t_fcat.

     DATA lt_trans_dtl_fcat TYPE lvc_t_fcat.

     CLEAR gt_copc_bal.

     APPEND LINES OF it_copc_bal TO gt_copc_bal.

     CLEAR gt_trans_detail.

     APPEND LINES OF it_trans_detail TO gt_trans_detail.

     _adjust_data_for_display( ).

     IF gv_grid_inited NE abap_true.

       CLEAR gs_grid_variant.

       CLEAR gs_grid_variant_detail.

       CLEAR gt_trans_dtl_fcat.

       gs_grid_layout-no_rowmark  = abap_true.

"      gs_grid_layout-sel_mode    = 'A'.

       gs_grid_layout-stylefname  = 'FLD_STYL'.

       gs_grid_variant-report     = sy-repid.

       gs_grid_variant-username   = sy-uname.

       gs_grid_variant-log_group  = '001'.

       "load account balance data to ALV

       CREATE OBJECT go_acc_bal_container

         EXPORTING

           container_name = 'ACC_BAL_CONTAIN'.

       CREATE OBJECT go_acc_bal_grid

         EXPORTING

           i_appl_events = abap_true

           i_parent      = go_acc_bal_container.

       CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

         EXPORTING

           i_structure_name = 'EPIC_S_COPC_BAL'

         CHANGING

           ct_fieldcat      = lt_acc_bal_fcat.

       DATA lt_acc_bal_fcat_a TYPE lvc_t_fcat.

       _adjust_bal_alv_dsp(

         EXPORTING

           it_fcat = lt_acc_bal_fcat    " Field Catalog for List Viewer Control

         IMPORTING

           et_fcat = lt_acc_bal_fcat_a   " Field Catalog for List Viewer Control

       ).

       go_acc_bal_grid->set_table_for_first_display(

         EXPORTING

             is_layout            = gs_grid_layout

             is_variant           = gs_grid_variant

             i_save               = 'A'

           CHANGING

             it_outtab            = gt_copc_bal

             it_fieldcatalog      = lt_acc_bal_fcat_a

              ).

       "load trasaction detail data to ALV

       CREATE OBJECT go_acc_trans_dtl_container

         EXPORTING

           container_name = 'TRANS_DTL_CONTAIN'.

       CREATE OBJECT go_acc_trans_dtl_grid

         EXPORTING

           i_appl_events = abap_true

           i_parent      = go_acc_trans_dtl_container.

       CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

         EXPORTING

           i_structure_name = 'COPC_S_TRANS_DETAIL'

         CHANGING

           ct_fieldcat      = lt_trans_dtl_fcat.

       DATA lt_trans_dtl_fcat_a TYPE lvc_t_fcat.

       _adjust_detail_alv_dsp(

         EXPORTING

           it_fcat = lt_trans_dtl_fcat    " Field Catalog for List Viewer Control

         IMPORTING

           et_fcat = gt_trans_dtl_fcat   " Field Catalog for List Viewer Control

       ).

       gs_grid_variant_detail = gs_grid_variant.

       gs_grid_variant_detail-log_group = '002'.

       go_acc_trans_dtl_grid->set_table_for_first_display(

         EXPORTING

             is_layout            = gs_grid_layout

             is_variant           = gs_grid_variant_detail

             i_save               = 'A'

           CHANGING

             it_outtab            = gt_trans_detail

             it_fieldcatalog      = gt_trans_dtl_fcat

              ).

       gv_grid_inited = abap_true.

     ENDIF.

     go_acc_bal_grid->refresh_table_display( ).

     go_acc_trans_dtl_grid->refresh_table_display( ).


I want to keep layout of ALV default setting when I enters screen each time. Please help me solve this problem.

1 REPLY 1

former_member220028
Active Contributor
0 Kudos

Hi,

are you refreshing ALV when pressing enter? maybe you should not refresh when pressing enter, or provide the right variant when refreshing.

regards

Stefan Seeburger