2008 Jun 05 11:44 AM
in Function module REUSE_ALV_GRID_DISPLAY how to add an extra pushbutton along with the layout, Excel buttons...
2008 Jun 05 11:49 AM
Go to the Documenation for REUSE_ALV_GRID_DISPLAY
and review the requirments for the parm I_CALLBACK_PF_STATUS_SET
You'll find this
Set EXIT rountine to status
Description
Passing an EXIT routine indicates to the ALV that the caller wants to set a self-defined user status.
As a result, the default status of the ALV is not set.
The interface of the form routine specified must be defined as follows:
FORM set_pf_status USING rt_extab TYPE slis_t_extab
Table RT_EXTAB contains the function codes that would be hidden on the standard user interface.
If the caller wants to use a self-defined user interface (for example, in order to provide additional list
functions or use existing functions), we recommend that you copy standard status STANDARD
from function group SALV and modify it accordingly. ALV standard function codes always start with '&'.
See also the documentation on parameter I_CALLBACK_USER_COMMAND.
If a self-defined user interface is used that includes function codes of the standard user interface,
the function codes of the excluding table passed should be taken into account.
This means that the user status should generally be set as follows:
SET PF-STATUS user status EXCLUDING rt_extab.
Application functions can be added to excluding table rt_extab if they are to be disabled.
The routine is called whenever the standard user interface would be set with SET PF-STATUS.
Default
If no EXIT routine is specified, the ALV sets a status that corresponds to status STANDARD of
function group SALV.
This is code that sets it up for use
FORM list_view.
*
g_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = 'STAT_0100'
is_layout = g_layout
it_sort = g_sort[]
it_events = g_events[]
it_fieldcat = g_fieldcat[]
i_save = g_save
it_excluding = g_exclude
TABLES
t_outtab = it_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e208(00) WITH 'Error: ALV Grid'.
ENDIF.
*
ENDFORM. " layout_build
*====> End of Actual Display Routine
*====> This establishes the custom PF Status
FORM stat_0100 USING my_exclude.
*
SET PF-STATUS 'STAT_0100' EXCLUDING my_exclude.
*
ENDFORM. "end custom PF Status
And the FORM that list all the common icons and what to use to exclude the ones you do not want.
Simply uncomment the ones you don't want to see.
*--------------------------------------------------------------*
* Form exclude_icons
*--------------------------------------------------------------*
FORM exclude_icons.
* APPEND '&ETA' TO g_exclude. "Details
** APPEND '&OUP' TO g_exclude. "Sort Up
** APPEND '&ODN' TO g_exclude. "Sort Down
* APPEND '&ILT' TO g_exclude. "Set Filter
* APPEND '&UMC' TO g_exclude. "Sum
** APPEND '&RNT_PREV' TO g_exclude. "Print preview
** APPEND '&VEXCEL' TO g_exclude. "Excel
** APPEND '&RNT_PREV' TO g_exclude. "Word processing
** APPEND '%PC' TO g_exclude. "Local File
** APPEND '%SL' TO g_exclude. "Mail recepient
* APPEND '&ABC' TO g_exclude. "ABC Analysis
* APPEND '&GRAPH' TO g_exclude. "Graphic
** APPEND '&OL0' TO g_exclude. "Change layout
** APPEND '&OAD' TO g_exclude. "Select layout
** APPEND '&AVE' TO g_exclude. "Save Layout
* APPEND '&AVE' TO g_exclude. "Information
ENDFORM. " exclude_icons
Edited by: Paul Chapman on Jun 5, 2008 6:52 AM
2008 Jun 05 11:49 AM
hi,
take a look at this code
*----------------------------------------------------------------------
* CLASS DECLARATION
*----------------------------------------------------------------------
CLASS lcl_event_receiver DEFINITION DEFERRED.
*----------------------------------------------------------------------
* CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object
ENDCLASS.
*----------------------------------------------------------------------
* CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
DATA:
lwa_tlbar TYPE stb_button.
lwa_tlbar-function = '&NEW'.
lwa_tlbar-icon = '@0Y@'. "ICON_CREATE
lwa_tlbar-quickinfo = 'New Record'.
lwa_tlbar-disabled = 'X'.
INSERT lwa_tlbar INTO e_object->mt_toolbar INDEX 1.
CLEAR lwa_tlbar.
lwa_tlbar-function = '&CHANGE'.
lwa_tlbar-icon = '@0Z@'. "ICON_CHANGE
lwa_tlbar-quickinfo = 'Change Record(s)'.
lwa_tlbar-disabled = 'X'.
INSERT lwa_tlbar INTO e_object->mt_toolbar INDEX 2.
CLEAR lwa_tlbar.
lwa_tlbar-function = '&DELETE'.
lwa_tlbar-icon = '@11@'. "ICON_DELETE
lwa_tlbar-quickinfo = 'Delete Record(s)'.
lwa_tlbar-disabled = 'X'.
INSERT lwa_tlbar INTO e_object->mt_toolbar INDEX 3.
CLEAR lwa_tlbar.
lwa_tlbar-function = '&SAVE'.
lwa_tlbar-icon = '@2L@'. "ICON_SYSTEM_SAVE
lwa_tlbar-quickinfo = 'Save Changes'.
lwa_tlbar-disabled = 'X'.
INSERT lwa_tlbar INTO e_object->mt_toolbar INDEX 5.
CLEAR lwa_tlbar.
lwa_tlbar-function = '&CANCEL'.
lwa_tlbar-icon = '@0W@'. "ICON_CANCEL
lwa_tlbar-quickinfo = 'Cancel Changes'.
lwa_tlbar-disabled = 'X'.
INSERT lwa_tlbar INTO e_object->mt_toolbar INDEX 6.
CLEAR lwa_tlbar.
ENDMETHOD.
ENDCLASS.
DATA:
go_alvgd TYPE REF TO cl_gui_alv_grid,
go_event TYPE REF TO lcl_event_receiver.
Create your ALV Grid here,
CREATE OBJECT go_event.
SET HANDLER go_event->handle_toolbar FOR go_alvgd.
regards,
Peter
2008 Jun 05 11:50 AM
hi,
u need to define PF_STATUS BAR and pass it to REUSE_ALV_GRID_DISPLAY in exporting........
i_callback_pf_status_set = 'SET_PF_STATUS'
i_callback_user_command = 'USER_COMMAND'
and declare the form which will get called when user clicks on the buttons..... in the eg. i have done it for back button....
but the toolbar u create shd be created in TCode SE41 by copying a toolbar from any program which will have all buttons which u want plus the new buttons which u want on the screen ......
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'TOOLBAR_1' .
ENDFORM. "set_pf_status
*FORM user_command using ucomm LIKE sy-ucomm .
FORM user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE sy-ucomm.
WHEN 'BACK'.
LEAVE TO SCREEN 1000.
ENDCASE.
ENDFORM. "user_command
reward points if useful......
2008 Jun 05 11:51 AM
Dear
No need to use separate button for ALV download to Excel
you can use Menu-List-Export or Local file tool to down load
if you want to use Button also u may need to use Customer Container in Screen area (like Envelope object)
Rewards if useful.
2008 Jun 05 11:51 AM
Hi,
U can add push button using th eimport parameter
I_CALLBACK_PF_STATUS_SET
read its documentation in the function module
2008 Jun 05 11:52 AM
Hi
U need to create an your own pf-status as copy of the std one: prg. SAPLKKBL status STANDARD_FULLSCREEN.
So set your status instead of std one by a routine like this:
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'MY_ALV' EXCLUDING T_EXTAB.
ENDFORM. " set_pf_status
U need to create a routine for the USER-COMMAND event:
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
ENDFORM.
So it needs to indicates the routine above while calling fm ALV:
GT_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
I_CALLBACK_PROGRAM = GT_REPID
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
Max
2008 Jun 05 12:00 PM
Hi ,
You just copy the standard Pf status in your program.
The interface of the form routine specified must be defined as follows:
FORM set_pf_status USING rt_extab TYPE slis_t_extab
Table RT_EXTAB contains the function codes that would be hidden on the
standard user interface.
If the caller wants to use a self-defined user interface (for example,
in order to provide additional list functions or use existing
functions),I recommend that you copy standard status STANDARD from
function group SALV and modify it accordingly. ALV standard function
codes always start with '&'.
In that GUI status just add another Fn code to the application toolbar and you will get the added fn code as button at your application toolbar with sy-ucomm as the fn code
2008 Jun 05 12:04 PM
Once ur problem is solved , mark the post as answered.... and reward points .....