Application Development and Automation 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: 
Read only

Refresh button in ALV grid display

Former Member
8,313

Hi All,

How can I add a refresh button in alv display.Through that  refresh button i have to change the data time to time in the report .

Regards,

Siva jyothi

Hi All,

How can I add a refresh button in alv display.Through that  refresh button i have to change the data time to time in the report .

Regards,

Siva jyothi

6 REPLIES 6
Read only

former_member226419
Contributor
0 Likes
4,614

Hi,

Search SCN before posting. Lots of threads available for the same.

data: fcode type table of sy-ucomm,

     wa_fcode type sy-ucomm.

start-of-selection.

  wa_fcode = 'FC2 '. append wa_fcode to fcode.

  wa_fcode = 'FC3 '. append wa_fcode to fcode.

  wa_fcode = 'FC4 '. append wa_fcode to fcode.

  wa_fcode = 'FC5 '. append wa_fcode to fcode.

  wa_fcode = 'PICK'. append wa_fcode to fcode.

  set pf-status 'TEST' of program 'DEMO_LIST_SET_PF_STATUS_1' excluding fcode.

  perform show_list.

at user-command.

  case sy-ucomm.

    when 'FC1'. perform show_list.

  endcase.

*&---------------------------------------------------------------------*

*&      Form  SHOW_LIST

*&---------------------------------------------------------------------*

*       text

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

form show_list.

  sy-lsind = sy-lsind - 1.

  write : sy-uzeit.

endform.                    "SHOW_LIST

Read only

FredericGirod
Active Contributor
0 Likes
4,614

Hi,

you have to redefine the toolbar

(my example is for a tree, but it's the same)

*---------------------------------------------------------------------*
*   CLASS lcl_toolbar_event_receiver DEFINITION                       *
*---------------------------------------------------------------------*

CLASS lcl_toolbar_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS: on_function_selected
               FOR EVENT function_selected OF cl_gui_toolbar
                 IMPORTING fcode.
ENDCLASS. "lcl_toolbar_event_receiver DEFINITION

DATA : obj_tree_toolbar   TYPE REF TO cl_gui_toolbar .



*---------------------------------------------------------------------*
*   Form P_CHANGE_TOOLBAR.                                            *
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*

FORM p_change_toolbar.


  CALL METHOD obj_tree->get_toolbar_object
    IMPORTING
      er_toolbar = obj_tree_toolbar.

* Test qu'il y a bien une barre d'outil.

  CHECK NOT obj_tree_toolbar IS INITIAL.

* Ajoute un separateur à la barre d'outil.

  CALL METHOD obj_tree_toolbar->add_button
    EXPORTING
      fcode     = ''
      icon      = ''
      butn_type = cntb_btype_sep
      text      = ''
      quickinfo = 'Seperator'.

* Ajoute le bouton détail simple / accés deuxieme ecran

  CALL METHOD obj_tree_toolbar->add_button
    EXPORTING
      fcode     = 'SM_TREE'
      icon      = '@CC@'
      butn_type = cntb_btype_button
      text      = ' SM '
      quickinfo = 'Sortie Marchandise'.

* Active la gestion des evenements sur la barre d'outil.

  CREATE OBJECT obj_tree_tevent.
  SET HANDLER obj_tree_tevent->on_function_selected
              FOR obj_tree_toolbar.

ENDFORM. " P_CHANGE_TOOLBAR

*---------------------------------------------------------------------*
*       CLASS lcl_toolbar_event_receiver IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*

CLASS lcl_toolbar_event_receiver IMPLEMENTATION.

* Methode On_Function_Selected

  METHOD on_function_selected.

    DATA : it_select_node TYPE lvc_t_nkey ,
           is_select_node TYPE lvc_nkey   ,
           is_data        TYPE ts_lipov .

*     Si bouton SM.

    IF fcode EQ 'SM_TREE'.

*       Recherche le numéro du noeud.

      CALL METHOD obj_tree->get_selected_nodes
        CHANGING
          ct_selected_nodes = it_select_node.
      CALL METHOD cl_gui_cfw=>flush.

*     Cole le numero dans une zone avec header-line.

      READ TABLE it_select_node INTO is_select_node INDEX 1.
      IF NOT is_select_node IS INITIAL.

*         Récupère la ligne

        CALL METHOD obj_tree->get_outtab_line
          EXPORTING
            i_node_key    = is_select_node
          IMPORTING
            e_outtab_line = is_data.

*       Vérifie que c'est une ligne : livraison

        CHECK ( NOT is_data-vbeln IS INITIAL AND
                    is_data-posnr IS INITIAL    ) OR
              ( NOT is_data-tknum IS INITIAL AND
                    is_data-vbeln IS INITIAL AND
                    is_data-posnr IS INITIAL    ).

*       Sortie Marchandise.

        PERFORM p_sm_delivery USING is_data-vbeln
                                    is_data-tknum.
      ELSE.
        MESSAGE i227(0h).
      ENDIF.

    ENDIF.


  ENDMETHOD.                    "on_function_selected


ENDCLASS. "lcl_toolbar_event_receiver IMPLEMENTATION

regards

Fred

Read only

ingoreddies
Explorer
0 Likes
4,614

This message was moderated.

Read only

Former Member
4,614

Its quite simple.

1. First add the refresh button in your GUI status with a function code, say &REF associated with it.

2. Suppose a subroutine get_data, gets data from the database using the select statement.

3.

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

      i_callback_program       = sy-cprog

      i_callback_pf_status_set = 'ZSTANDARD' - " THis should have the refresh button also.

      i_callback_user_command  = 'USER_COMMAND'

      it_fieldcat              = lt_fieldcat

      it_event_exit            = lt_event_exit

    TABLES

      t_outtab                 = gt_mara.

4.

FORM user_command USING u_ucomm     TYPE sy-ucomm

                        r_selfield TYPE slis_selfield.     "#EC CALLED

  CASE u_ucomm.

    WHEN '&REF'..

      PERFORM get_data.       " Refresh data, get the latest data from database to the output table.

      r_selfield-refresh    = 'X'.

      r_selfield-col_stable = 'X'.

      r_selfield-row_stable = 'X'.

  ENDCASE.

ENDFORM.                    "user_command

Read only

0 Likes
4,614

Hi Susmitha,

I have a requirement of adding push buttons on ALV output.

I am using CL_SALV_TABLE for showing the output of my report.

Please share your ideas if any about adding of Push button like Select All, De-Select All, Process, Delete etc..

Regards,

Mohammed

Read only

0 Likes
4,614

Hi,

     In order to create a pushbutton in ALV grid output screen, always remember to first copy the STATUS from the standard SAP program: SAPLKKBL .For this goto: SE90 or SE 80 & goto GUI status & put in this program name & execute it & then copy the standard status to the status which you will be creating for your program.After copying the standard status u can go to ur program & double click ur status (SET PF_STATUS 'ZSTANDARD'.) & add a pushbutton to the standard copied status.Save & activate & then u can code the function for that pushbutton.


Regards,

Kushi