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: 

button on application bar in alv reports

Former Member
0 Kudos

Hi

I want to add display button on application toolbar in alv reports and want to assign functionality to it

can u plz tell how to do that in case of alv.

12 REPLIES 12

Former Member
0 Kudos

Hi,

You can create GUI-Status and add buttons.

Regards,

Srikanth Peri

Former Member
0 Kudos

can u plz tell me how to do that in case of alv report.

0 Kudos

Hi Prakash,

You need to create a button in Application toolbar using GUI_STATUS through SE51.

For that button you need to Assign a Function Code (UCOMM).

Then use that in your program.

SET GUI_STATUS....

Then write code for Module User Command.


Case SY-UCOMM.
WHEN " The one that you assigned
    Perform necessary action
ENDCASE. 

Hope you are clear.

Best Regards,

Ram.

Edited by: ram Kumar on Dec 12, 2008 11:45 AM

Former Member
0 Kudos

just execute u alv program in the o/p list goto >system--->status.

get the program name and status name....

goto se51..

click button (copy status) in application toolbar....

give the above program name in from.

and give ur program name and staus name in to..

click copy..

now every thing in standard menu will be copied to ur status ...here in ur status u can put ur own pushbutton.....

Former Member
0 Kudos

Hi Prakash,

Create your own GUI Status with the tool bar buttons you want,

then call the ALV display function as below,

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
*   I_INTERFACE_CHECK                 = ' '
*   I_BYPASSING_BUFFER                = ' '
*   I_BUFFER_ACTIVE                   = ' '
     i_callback_program                = gd_repid
*   I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
   i_callback_user_command           = 'USER_COMMAND'

Then for doing the necessary action you have to create form for user command as below,

FORM user_command USING r_ucomm LIKE sy-ucomm.
CASE r_ucomm.

    WHEN 'Function code of the button'.
     .
     .
     .
ENDCASE.

ENDFORM.

Hope this will help you.

Regards,

Manoj Kumar P

MarcinPciak
Active Contributor
0 Kudos

Hi,

If you are using classical ALV grid or list you can do as Srikanth said.

If you are using OO ALV you have to handle event TOOLBAR (in order to add and handle button) like below:


"create local class for handling TOOLBAL event
CLASS lcl_gui_alv_event_receiver 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.

"implement it
CLASS lcl_gui_alv_event_receiver IMPLEMENTATION.
"Handle Toolbar
  METHOD handle_toolbar.
    DATA: ls_toolbar TYPE stb_button.


" append a separator to normal toolbar
    CLEAR ls_toolbar.
    MOVE 3 TO ls_toolbar-butn_type.   "separator
    APPEND ls_toolbar TO e_object->mt_toolbar.

" append a button + icon + text to it
    CLEAR ls_toolbar.
    MOVE 0 to ls_toolbar-butn_type.   "button
    MOVE icon_simulate TO ls_toolbar-icon.
    MOVE text-tl0 TO ls_toolbar-text.
    MOVE '&NO' TO ls_toolbar-function.   "your funtion code here of a button
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
  ENDMETHOD.                    "handle_toolbar


DATA: g_alv_event_ref TYPE REF TO lcl_gui_alv_event_receiver,
          g_alv_grid_ref TYPE REF TO cl_gui_alv_grid.

"now set the handler for the event
 SET HANDLER  g_alv_event_ref->handle_toolbar FOR g_alv_grid_ref.

"finally tell ALV grid to show your button
CALL METHOD g_alv_grid_ref->set_toolbar_interactive.

Regards

Marcin

Former Member
0 Kudos

goto se80 then click on the GUI status you will find three items

there you will click on application toolbar

there will be some items you need to check write a name ZZZZ and below it click then you will find a popup where you will have to select dyanmic text and the press ok you will get another popup where you need to fill the icon name and icon text and press ok. the you will find one more popup where you need to select one function and after that select a function and then press ok. you will come back to the main screen you need to activate it then activate the whole program and execute it. if wanting to add any fuctionality you nee to use ok_code.

Hope your resolve the issue

Cheers

Former Member
0 Kudos

Hi,

Set button in PF status.

then catch sy-ucomm.

Thanks & Regards,

Krishna..

Former Member
0 Kudos

HI,

Below code can help you..

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK =

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = SY-REPID

i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = 'USER_COMMAND'

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

it_fieldcat = fcat[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = itab

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

&----


*& Form set_pf_status

&----


  • Set PF-STATUS for user's push button

----


FORM set_pf_status USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZNEWSTATUS'.

*double click on this 'ZNEWSTATUS' , here u can define your own button within application bar. Give the *Function code as 'BUTTON' (in my case) then save n activate it.

ENDFORM. " PF_STATUS_NEW

&----


*& Form user_command

&----


  • Click on button gives popup information

----


FORM user_command USING ucomm LIKE sy-ucomm

selfield TYPE slis_selfield.

lv_ucomm

= sy-ucomm.

CASE lv_ucomm.

WHEN 'BUTTON'.

MESSAGE 'Working well' TYPE 'I'.

ENDCASE.

ENDFORM. "user_command

I355602
Advisor
Advisor
0 Kudos

Hi,

Goto SE41 --> create a pf-status for your alv report --> goto menu EXTRAS --> click ADJUST TEMPLATE --> select LIST VIEWER

You will get all the standard ALV buttons. Delete buttons that you dnt need and add new buttons as per your requirement.

And now apply this pf-status in program as:-


  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     i_callback_program                = v_rep_id       " report id
     i_callback_pf_status_set          = 'PF'           " for PF-STATUS
     i_callback_user_command           = 'USER_COMMAND' " for User-Command
     is_layout                         = wa_layout      " for layout
     it_fieldcat                       = it_field       " field catalog
     it_sort                           = it_sort        " sort info
    TABLES
      t_outtab                          = it_final      " internal table
   EXCEPTIONS
     program_error                     = 1
     OTHERS                            = 2.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

*&---------------------------------------------------------------------*
*&      Form  pf
*&---------------------------------------------------------------------*
*       SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
*       ON WHICH THE ALV GRID IS DISPLAYED
*----------------------------------------------------------------------*
*       -->RT_EXTAB
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZTG_STAT'.
ENDFORM.                    "pf

*&---------------------------------------------------------------------*
*&      Form  USER_COMMAND
*&---------------------------------------------------------------------*
*       SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
*       AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
*      -->LV_OKCODE   used to capture the function code
*                     of the user-defined push-buttons
*      -->L_SELFIELD   text
*----------------------------------------------------------------------*
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.

* assign the function code to variable v_okcode
  lv_okcode = sy-ucomm.

* handle the code execution based on the function code encountered
  CASE lv_okcode.

* when the function code is <func_code> then process
    WHEN '<func_code>'.
      "your code

  ENDCASE.

ENDFORM.                    "USER_COMMAND

Hope this helps you.

Regards,

Tarun

Former Member
0 Kudos

hi,

Set PF Status can be used, and u can have ur Button there , and at PAI give ur logic.

Thanks

Suraj

sarbajitm
Contributor
0 Kudos

First you have to create a PF-STATUS using SE41.

Then in the ALV You have to set the following parameter:

Like for Gird display ALV ,in the FM 'REUSE_ALV_GRID_DISPLAY' you have to set the parameter

i_callback_pf_status_set = 'PF_STATUS_SET'

then you have to create a subroutine with the same name of the parameter, like in this case, PF_STATUS_SET as follows:

FORM pf_status_set USING rt_extab TYPE slis_t_extab.

SET PF-STATUS 'ZSTANDARD' OF PROGRAM 'ZSAR_ASSGN1_GRIDALV'

ENDFORM.

Hope this will solve your problem.

Thanks.