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: 

Single Scroll Bar for multiple ALV

Former Member
0 Kudos

Hi Experts,

I have a requirement, i am placing 5 ALVs in a module pool screen which consist of 20 to 30 fields in each alv.i have done this by creating custom containers using OO ALV. As it consist of multiple fields we are getting horizontal scroll bars for each alv. so customer requirement was to place single 

scroll bar for all ALVs  .

Thanks,

Charan Tej

1 ACCEPTED SOLUTION

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

Please look a my blog entry on this subject using the code in my responses here

Regards.

14 REPLIES 14

Former Member
0 Kudos

Charan,

I don't think this is possible since each ALV is an object independent of the others which sits in its own container.

I might be wrong and will check what others say.

Thanks,

Vikram.M

former_member182466
Contributor
0 Kudos

The only way you can do this is to make the screen so wide that the ALV's do not get scollbars, you then will get a scroll bar for the screen which will scroll all the tables. Note that this solution is not really scalable and that you cannot lock any key columns.

0 Kudos

Hi Gerrit Beukema,

I have taken maximum screen size 200 width and 255 height given by sap. The problem was not resolved.As i am using Dynamic internal table for the ALV the fields get increasing based on some condition so they don't want horizontal scroll bar for each alv.instead of this they need single scroll bar for all the the ALVs.

Thanks,

Charan Tej

0 Kudos

Could you please show a screenshot? (because I'm not sure to understand what your problem is ; having a very wide screen is not really handful, it should be limited).

Moreover, why don't you define only one ALV?

0 Kudos

Hi Sandra,

i have attached the screen shot we developed.

The fields in ALV will be dynamically added as fields get increased horizontal scroll bar is getting for each ALV .so they need only one scroll bar for all ALVs. Instead of having scroll bar for all alvs.

Thanks,

Charan Tej

0 Kudos

As already said, it's impossible to scroll all ALVs at the same time, you must make them fully contained in the screen (max width of 200 characters). Possibly, you could have one scrollbar for all of them, by defining a subscreen 200 characters wide, containing a custom container with a splitter with all 5 ALVs, still none of the ALVs should have any scrollbar, but if you include the subscreen inside a subscreen area of say 150 characters wide, there will then be a horizontal scrollbar for the subscreen area, to scroll the whole content i.e. the 5 ALVs.

Note that in your example, you lose space by keeping the default column widths. You should calculate them automatically (column width optimize).

0 Kudos

Hello Sandra ,

Please have a look at my proposal .

When using a grid with many columns we have to use key fields ( lvc_s_fcat-key ) .

When using ob_gui_alv_grid->set_scroll_info_via_id the system respect the key fields.

This way the user have a point of reference .

Regards.

0 Kudos

You're right, Eitan, we may also scroll programmatically any number of grids we want by a custom button, as you did, and react by calling method SET_SCROLL_INFO_VIA_ID at every grid, to scroll the grids automatically. The scrollbar at each ALV grid could still be used for scrolling ALVs independently.

0 Kudos

Hi,

Actually I am working on an article to demonstrate the idea the screen looks like this:

Regards.

Eitan.

Chintu6august
Contributor
0 Kudos

Hi,

ALV containers are independent of screen and other containers, you can increase the width of the screen and width of custom container in the layout!!

thank you!!

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

Thinking aloud...

We do have in CL_GUI_ALV_GRID method SET_SCROLL_INFO_VIA_ID

I never used the IS_COL_INFO but it seems that you can (by adding some buttons and code....) utilize it .

Worth a try.

Also have a look at BCALV_TEST_GRID_INDEX

Regards.

Eitan.

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

Some fresh code... (fragments)

In my program level cl_event_receiver:

  PUBLIC SECTION.

    CONSTANTS: c_column_left  TYPE syucomm VALUE 'COLUMN_LEFT'  ,

               c_column_right TYPE syucomm VALUE 'COLUMN_RIGHT' .

  METHODS: toolbar

             FOR EVENT toolbar OF cl_gui_alv_grid

             IMPORTING e_object e_interactive .

            

METHODS: user_command

             FOR EVENT user_command OF cl_gui_alv_grid

             IMPORTING e_ucomm .

                         

*----------------------------------------------------------------------*

  METHOD toolbar.

    FIELD-SYMBOLS: <st_toolbar> LIKE LINE OF e_object->mt_toolbar .

    APPEND INITIAL LINE TO e_object->mt_toolbar ASSIGNING <st_toolbar> .

    <st_toolbar>-function = c_column_left .

    <st_toolbar>-icon = icon_column_left .

    APPEND INITIAL LINE TO e_object->mt_toolbar ASSIGNING <st_toolbar> .

    <st_toolbar>-function = c_column_right .

    <st_toolbar>-icon = icon_column_right .

  ENDMETHOD.                    "handle_toolbar

*----------------------------------------------------------------------*

  METHOD user_command .

 

   DATA: it_fieldcatalog TYPE lvc_t_fcat .

   DATA: st_fieldcatalog LIKE LINE OF it_fieldcatalog .

    DATA: st_row_no       TYPE lvc_s_roid .

    DATA: st_row_info     TYPE lvc_s_row .

    DATA: st_col_info     TYPE lvc_s_col . 

   

CASE e_ucomm.

   WHEN cl_event_receiver=>c_column_right OR

           cl_event_receiver=>c_column_left .

        ob_gui_alv_grid_1->get_scroll_info_via_id( IMPORTING

            es_row_no   = st_row_no

            es_col_info = st_col_info

            es_row_info = st_row_info

        ) .

        ob_gui_alv_grid_1->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = it_fieldcatalog ) .

        DELETE it_fieldcatalog WHERE no_out EQ abap_true .

        DELETE it_fieldcatalog WHERE tech   EQ abap_true .

        READ TABLE it_fieldcatalog INTO st_fieldcatalog

        WITH KEY

          fieldname = st_col_info-fieldname .

        CHECK sy-subrc EQ 0 .

        CASE e_ucomm .

          WHEN cl_event_receiver=>c_column_right .

            st_fieldcatalog-col_pos = st_fieldcatalog-col_pos + 1 .

          WHEN cl_event_receiver=>c_column_left  .

            st_fieldcatalog-col_pos = st_fieldcatalog-col_pos - 1 .

          WHEN OTHERS.

        ENDCASE.

        READ TABLE it_fieldcatalog INTO st_fieldcatalog

        WITH KEY

          col_pos = st_fieldcatalog-col_pos .

        CHECK sy-subrc EQ 0 .

        st_col_info-fieldname = st_fieldcatalog-fieldname .

        ob_gui_alv_grid_1->set_scroll_info_via_id( EXPORTING

             is_row_no   = st_row_no

             is_col_info = st_col_info

             is_row_info = st_row_info

         ) .

    ENDCASE.

  ENDMETHOD .                    "handle_user_command

*----------------------------------------------------------------------*

In your case you might need to put the buttons in a status not in the individual grids .

you have to repeat the code for each grid (hint: create a static method that will accept a grid as parameter )

Regards.

Eitan.

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

Small update: (A bug found by my teammate Haim Bracha )

And using CLASS-METHODS

  CLASS-METHODS: user_command_scroll

                   IMPORTING

                     e_ucomm         TYPE syucomm

                     ob_gui_alv_grid TYPE REF TO cl_gui_alv_grid .

*----------------------------------------------------------------------*

  METHOD user_command_scroll .

    DATA: it_fieldcatalog TYPE lvc_t_fcat .

    DATA: st_fieldcatalog LIKE LINE OF it_fieldcatalog .

    DATA: st_row_no       TYPE lvc_s_roid .

    DATA: st_row_info     TYPE lvc_s_row .

    DATA: st_col_info     TYPE lvc_s_col .

    ob_gui_alv_grid->get_scroll_info_via_id( IMPORTING

        es_row_no   = st_row_no

        es_col_info = st_col_info

        es_row_info = st_row_info

    ) .

    ob_gui_alv_grid->get_frontend_fieldcatalog( IMPORTING et_fieldcatalog = it_fieldcatalog ) .

    DELETE it_fieldcatalog WHERE no_out EQ abap_true .

    DELETE it_fieldcatalog WHERE tech   EQ abap_true .

    SORT it_fieldcatalog BY col_pos .

    FIELD-SYMBOLS: <st_fieldcatalog> LIKE LINE OF it_fieldcatalog .

* Resequence

    LOOP AT it_fieldcatalog ASSIGNING <st_fieldcatalog> .

      <st_fieldcatalog>-col_pos = sy-tabix .

    ENDLOOP .

    READ TABLE it_fieldcatalog into st_fieldcatalog

    WITH KEY

      fieldname = st_col_info-fieldname .

    CHECK sy-subrc EQ 0 .

    CASE e_ucomm .

      WHEN cl_event_receiver=>c_column_right .

        st_fieldcatalog-col_pos = st_fieldcatalog-col_pos + 1 .

      WHEN cl_event_receiver=>c_column_left  .

        st_fieldcatalog-col_pos = st_fieldcatalog-col_pos - 1 .

      WHEN OTHERS.

    ENDCASE.

    READ TABLE it_fieldcatalog INTO st_fieldcatalog

      WITH KEY

        col_pos = st_fieldcatalog-col_pos .

    CHECK sy-subrc EQ 0 .

    st_col_info-fieldname = st_fieldcatalog-fieldname .

    ob_gui_alv_grid->set_scroll_info_via_id( EXPORTING

         is_row_no   = st_row_no

         is_col_info = st_col_info

         is_row_info = st_row_info

     ) .

  ENDMETHOD .                    "user_command_scroll

*----------------------------------------------------------------------*

In user_command we have :

*----------------------------------------------------------------------*

  METHOD user_command .

    CASE e_ucomm.

      WHEN cl_event_receiver=>c_column_right OR

           cl_event_receiver=>c_column_left .

        user_command_scroll( EXPORTING e_ucomm = e_ucomm ob_gui_alv_grid = ob_gui_alv_grid_1 ) .

    ENDCASE.

  ENDMETHOD .                    "handle_user_command

*----------------------------------------------------------------------*

Regards.

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

Please look a my blog entry on this subject using the code in my responses here

Regards.