Skip to Content
avatar image
Former Member

Can we scroll to the last page of an alv grid?

I am dispalying a report in ALV grid format - REUSE_ALV_GRID_DISPLAY.

As soon as the execute button is clicked it should show the last page with the totals.

User will then scroll upwards to see the details.

How to scroll to the end of the ALV grid?

(It is like goign to the last page of course)

Thanks,

Ven

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 09, 2008 at 06:32 PM

    Hi,

    Yes..You can do it using the OO ALV...You can use the method set_current_cell_via_id ..to show the last record.

    Check this example.

    * Declarations.
    DATA: l_lines TYPE int4,
          l_row_no TYPE lvc_s_roid.
    DATA: ok_code LIKE sy-ucomm,
          g_container TYPE scrfname VALUE 'CONTAINER1',
          g_grid  TYPE REF TO cl_gui_alv_grid,
          g_custom_container TYPE REF TO cl_gui_custom_container,
          gs_layout TYPE lvc_s_layo.
    
    DATA: gt_outtab TYPE TABLE OF t001w.
    DATA: v_count TYPE i.
    
    *---------------------------------------------------------------------*
    *       MAIN                                                          *
    *---------------------------------------------------------------------*
    CALL SCREEN 100.
    
    *---------------------------------------------------------------------*
    *       MODULE PBO OUTPUT                                             *
    *---------------------------------------------------------------------*
    MODULE pbo OUTPUT.
    
      SET PF-STATUS 'TEST'.
      SET TITLEBAR 'MAIN100'.
    
    * Create the grid.
      IF g_custom_container IS INITIAL.
        CREATE OBJECT g_custom_container
          EXPORTING
            container_name = g_container.
        CREATE OBJECT g_grid
          EXPORTING
            i_parent = g_custom_container.
    
    * Get the data.
        SELECT * FROM t001w INTO TABLE gt_outtab.
    
        CALL METHOD g_grid->set_table_for_first_display
          EXPORTING
            i_structure_name = 'T001W'
            is_layout        = gs_layout
          CHANGING
            it_outtab        = gt_outtab.
    
        DESCRIBE TABLE gt_outtab LINES l_lines.
    
    * Go to the last row.
        l_row_no-row_id =  l_lines.
        CALL METHOD g_grid->set_current_cell_via_id
          EXPORTING
            is_row_no = l_row_no.
    
      ENDIF.
    ENDMODULE.                    "pbo OUTPUT
    *---------------------------------------------------------------------*
    *       MODULE PAI INPUT                                              *
    *---------------------------------------------------------------------*
    MODULE pai INPUT.
      CASE sy-ucomm.
        WHEN 'EXIT' OR 'BACK'.
          PERFORM exit_program.
      ENDCASE.
    ENDMODULE.                    "pai INPUT
    *---------------------------------------------------------------------*
    *       FORM EXIT_PROGRAM                                             *
    *---------------------------------------------------------------------*
    FORM exit_program.
      LEAVE PROGRAM.
    ENDFORM.                    "exit_program

    Thanks

    Naren

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 09, 2008 at 05:56 PM

    it is not possible to show the last page. if you have subtotals then can do this..

    in the sort you have expa if you set this expa to 'X' all the subnodes will be collapsed.

    so you can see all the totals etc. then you can expand and see the details if you want.

    sort-fieldname = 'FIELDNAME'.
    sort-subtot = 'X'.
    sort-up = 'X'.
    sort-expa = 'X'.
    append sort to it_sort.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Is it possible to scroll by using methods?

      When I use a container and object oriented code, it brings in a default pf-status. On this when I click on the create button it is scrolling to the bottm and adding lines.

      (BCALV_EDIT_02, 04 etc).

      However I am not able to use the buttons here as I am not able to get a control over them. (These are not going into debug mode).

      Thanks,

      Ven,

  • Oct 09, 2008 at 06:45 PM

    I don't know if is it possible to scroll to last page of ALV, but you can bring the total on the very first line.

    In the LAYOUT we have a option to bring the Total on the first line. Like:

    data: LS_LAYOUT TYPE  SLIS_LAYOUT_ALV .
    ls_layout-totals_before_items = 'X'.
    

    Regards,

    Naimesh Patel

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 09, 2008 at 07:01 PM

    If you don't want to move the totals to first line you can scroll the list in the Classcial ALV also.

    1. You need to get the Grid object from the ALV using the FM GET_GLOBALS_FROM_SLVC_FULLSCR

    2. Call method to set_current_cell_via_id to last line.

    You need to call this grid object before it generates the output. So, good palce would be the TOP_OF_PAGE routine.

    * get the global reference
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
       IMPORTING
          e_grid                           = lo_grid.
    
    * Go to the last row.
        DATA: la_row_no TYPE lvc_s_roid.
        describe table it_bkpf lines sy-index.
        la_row_no-row_id =  sy-index.
        CALL METHOD lo_grid->set_current_cell_via_id
          EXPORTING
            is_row_no = la_row_no.
    

    You can check the the entired code which has the same kind of concept on my professional blog: [Classical ALV: Change Subtotal |http://help-abap.blogspot.com/2008/09/classical-alv-change-subtotal.html]

    Thanks to Narendran to point out me towards the SET_CURRENT_CELL_VIA_ID method.

    Regards,

    Naimesh Patel

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Ven,

      using the

      CALL FUNCTION 'REUSE_ALV_GRID_LAYOUT_INFO_SET'

      EXPORTING

      is_grid_scroll = ls_scroll_grid.

      i become a

      "Laufzeitfehler GETWA_NOT_ASSIGNED

      Kurztext Feldsymbol ist noch nicht zugewiesen

      Programm SAPLSLVC

      Include LSLVCU07

      Modulname LVC_TRANSFER_FROM_KKBL0"

      Do you know, what is the Problem?

      Thanks

  • avatar image
    Former Member
    Oct 10, 2008 at 07:45 PM

    Resolved as per the details mentioned above

    Add comment
    10|10000 characters needed characters exceeded