Skip to Content
avatar image
Former Member

Add Button with ALV Standard Toolbar.

Hi,

Can any one tell me how to add user-defined button with ALV

Standard toolbar? When I add Pf-status for alv output , standard alv toolbar is not displayed.

Plz do needful.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    avatar image
    Former Member
    Mar 20, 2008 at 06:22 AM

    On the toolbar event of your alv grid, all the button as shown in the code below.

    
    FORM handle_toolbar USING i_object TYPE REF TO cl_alv_event_toolbar_set .
    DATA: ls_toolbar TYPE stb_button.
     
    CLEAR ls_toolbar.
    MOVE 'EXCH' TO ls_toolbar-function. "#EC NOTEXT
    MOVE 2 TO ls_toolbar-butn_type.
    MOVE icon_calculation TO ls_toolbar-icon.
    MOVE 'Payment in Other Currencies'(202) TO ls_toolbar-quickinfo.
    MOVE ' ' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
    APPEND ls_toolbar TO i_object->mt_toolbar.
    ENDFORM
     
     
    CLASS lcl_event_handler DEFINITION .
    PUBLIC SECTION .
    METHODS:
    *To add new functional buttons to the ALV toolbar
    handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
    IMPORTING e_object e_interactive ,
    ENDCLASS.
     
    CLASS lcl_event_handler IMPLEMENTATION .
    *Handle Toolbar
    METHOD handle_toolbar.
    PERFORM handle_toolbar USING e_object e_interactive .
    ENDMETHOD .
    ENDCLASS.
     
    DATA gr_event_handler TYPE REF TO lcl_event_handler .
    .. ..
    *--Creating an instance for the event handler
    CREATE OBJECT gr_event_handler .
    *--Registering handler methods to handle ALV Grid events
    SET HANDLER gr_event_handler->handle_toolbar FOR gr_alvgrid .
     
     
    

    Hope this helps.

    Thanks,

    Balaji

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 20, 2008 at 06:30 AM

    HI

    Do the following to add button(s) to ALV toolbar:

    CLASS lcl_event_receiver DEFINITION.
    
      PUBLIC SECTION.
        METHODS:
                handle_toolbar
                FOR EVENT toolbar OF cl_gui_alv_grid
                    IMPORTING e_object e_interactive,
    
    ENDCLASS.  
    
    CLASS lcl_event_receiver IMPLEMENTATION.
    
      METHOD handle_toolbar.
        DATA: lv_toolbar TYPE stb_button.
    
    * Push Button 
          CLEAR lv_toolbar.
          MOVE gc_fc TO lv_toolbar-function.
          MOVE '<write text here for button>'(100) TO lv_toolbar-text.
          MOVE '<wrte text here>'(100) TO lv_toolbar-quickinfo.
          MOVE gc_space TO lv_toolbar-disabled.
          APPEND lv_toolbar TO e_object->mt_toolbar.
    
    endmethod.
    endclass.
    
    
      DATA: gv_event_receiver TYPE REF TO lcl_event_receiver,
    gv_alv_grid        TYPE REF TO cl_gui_alv_grid,
    
     CREATE OBJECT gv_event_receiver.
    
    * Event Handler
        SET HANDLER gv_event_receiver->handle_toolbar FOR gv_alv_grid.

    Thanks

    Vijay

    PLZ reward points if helpful

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 20, 2008 at 06:24 AM

    Hi,

    Check out page 33 of this PDF link.

    http://www.abap4.it/download/ALV.pdf

    It will solve ur problem.

    Reward if helpful.

    Regards,

    Ramya

    .

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 20, 2008 at 06:24 AM

    HI,

    U should copy the status of ur normal alv output after that

    u should go to se41 screen here one satus button there

    here In from u should give ur copied status name and program name

    in to u should give ur progarm name and ur own status name.

    and click copy.

    After u copied u can include ur button in application toolbar which u have copied status.

    now u can assign the pf-status in ur ALV program.

    Regards,

    S.Nehru.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 20, 2008 at 06:26 AM

    Hi,

    Firstly pass the PF-status from in which you will be having PF-status.

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    • I_INTERFACE_CHECK = ' '

    i_bypassing_buffer = 'X'

    i_buffer_active = ' '

    i_callback_program = sy-repid

    i_callback_pf_status_set = 'SET_PF_STATUS'

    'SET_PF_STATUS' is the FORM in which you will be having your pf-status 'PFSTATUS'

    FORM set_pf_status USING rt_extab TYPE slis_t_extab.

    SET PF-STATUS 'PFSTATUS' EXCLUDING rt_extab.

    ENDFORM.

    excluding rt_extab command will exclude SAP button,if you require SAP buttons to then remov ethe command.

    Click on the 'PFSTATUS' and put your button in APPLICATION toolbar.

    Regards,

    Prakash

    Add comment
    10|10000 characters needed characters exceeded