2008 Feb 07 10:05 AM
I want to add my own button along with the other buttons on alv grid.
Kindly give me a solution.
2008 Feb 07 10:08 AM
Hi,
You can copy the standard GUI status
Program Name: SAPLSLVC_FULLSCREEN.
GUI Status : STANDARD_FULLSCREEN.
and then add your own button.
Jayant Sahu
I want to add my own button along with the other buttons on alv grid.
Kindly give me a solution.
2008 Feb 07 10:08 AM
Hi,
You can copy the standard GUI status
Program Name: SAPLSLVC_FULLSCREEN.
GUI Status : STANDARD_FULLSCREEN.
and then add your own button.
Jayant Sahu
2008 Feb 07 10:13 AM
Make your own pf-status .
then goto se41.
goto copy status button and click.
enter details in dialog box
Program Name: SAPLSLVC_FULLSCREEN.
GUI Status : STANDARD_FULLSCREEN.
and
Program Name: your program name.
GUI Status : pf-status name.
click copy.
now come to ur program and goto your pf-status name and double click there.
now u can enter ur buttons here and activate GUI status.
<REMOVED BY MODERATOR>
keep rockin
vivek
Edited by: Alvaro Tejada Galindo on Jul 25, 2008 10:44 AM
2008 Feb 07 10:10 AM
Hi,
Please refer to the link below:
http://www.sapdev.co.uk/reporting/alv/alvgrid_pfstatus.htm
Thanks,
Sriram Ponna.
2008 Feb 07 10:10 AM
Hi,
This report shows you how to add a custom button to your ALV grid control.
DATA
Predefine a local class for event handling to allow the
declaration of a reference variable before the class is defined.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: custom_container1 TYPE REF TO cl_gui_custom_container,
cont_on_main TYPE scrfname VALUE 'ALV_GRID',
grid1 TYPE REF TO cl_gui_alv_grid,
event_receiver TYPE REF TO lcl_event_receiver,
okcode LIKE sy-ucomm.
DATA: gt_fieldcat TYPE slis_t_fieldcat_alv,
gt_fieldcat1 TYPE lvc_t_fcat,
gs_layout TYPE slis_layout_alv,
gs_layout1 TYPE lvc_s_layo,
gs_print TYPE slis_print_alv,
gt_sort TYPE slis_t_sortinfo_alv,
gt_sp_group TYPE slis_t_sp_group_alv,
gt_events TYPE slis_t_event,
gt_list_top_of_page TYPE slis_t_listheader.
DATA:t_out TYPE TABLE OF zstruct,
t_out_wa LIKE zstruct.
****************************************************************
LOCAL CLASSES: Definition
****************************************************************
*===============================================================
class lcl_event_receiver: local class to
define and handle own functions.
Definition:
~~~~~~~~~~~
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object e_interactive,
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm.
PRIVATE SECTION.
ENDCLASS.
****************************************************************
LOCAL CLASSES: Implementation
****************************************************************
*===============================================================
class lcl_event_receiver (Implementation)
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_toolbar.
§ 2.In event handler method for event TOOLBAR: Append own functions
by using event parameter E_OBJECT.
DATA: ls_toolbar TYPE stb_button.
*....................................................................
E_OBJECT of event TOOLBAR is of type REF TO CL_ALV_EVENT_TOOLBAR_SET.
This class has got one attribute, namly MT_TOOLBAR, which
is a table of type TTB_BUTTON. One line of this table is
defined by the Structure STB_BUTTON (see data deklaration above).
*
A remark to the flag E_INTERACTIVE:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'e_interactive' is set, if this event is raised due to
the call of 'set_toolbar_interactive' by the user.
You can distinguish this way if the event was raised
by yourself or by ALV
(e.g. in method 'refresh_table_display').
An application of this feature is still unknown...
append a separator to normal toolbar
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO e_object->mt_toolbar.
append an icon to show booking table
CLEAR ls_toolbar.
MOVE 'COMMENT' TO ls_toolbar-function.
MOVE icon_annotation TO ls_toolbar-icon.
MOVE 'Insert Comment'(001) TO ls_toolbar-quickinfo.
MOVE 'Notes'(004) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
MOVE 'MATNR' TO ls_toolbar-function.
MOVE icon_material TO ls_toolbar-icon.
MOVE 'View Material'(002) TO ls_toolbar-quickinfo.
MOVE 'Material'(003) TO ls_toolbar-text.
MOVE ' ' TO ls_toolbar-disabled.
APPEND ls_toolbar TO e_object->mt_toolbar.
ENDMETHOD.
*----
-
METHOD handle_user_command.
§ 3.In event handler method for event USER_COMMAND: Query your
function codes defined in step 2 and react accordingly.
DATA: lt_rows TYPE lvc_t_row.
CASE e_ucomm.
WHEN 'COMMENT'.
CALL METHOD grid1->get_selected_rows
IMPORTING et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ELSE.
PERFORM get_comment TABLES lt_rows. Perform action
ENDIF.
WHEN 'MATNR'.
CALL METHOD grid1->get_selected_rows
IMPORTING et_index_rows = lt_rows.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
add your handling, for example
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
titel = g_repid
txt2 = sy-subrc
txt1 = 'Error in Flush'(500).
ELSE.
READ TABLE lt_rows INDEX 1.
IF sy-subrc = 0.
READ TABLE t_out INTO t_out_wa INDEX lt_rows-index.
IF sy-subrc = 0.
SET PARAMETER ID 'MAT' FIELD t_out_wa-matnr.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN. "View Material
ELSE.
MESSAGE i999(b1) WITH 'Entry not found!'.
ENDIF.
ELSE.
MESSAGE i999(b1) WITH 'Please select a line first!'.
ENDIF.
ENDIF.
ENDCASE.
ENDMETHOD. "handle_user_command
*----
-
ENDCLASS.
*
lcl_event_receiver (Implementation)
*===================================================================
PBO
process before output.
MODULE STATUS_2000.
module init_data.
module create_container.
*&----
*
*& Module create_container OUTPUT
*&----
*
module create_container output.
if custom_container1 is initial.
create a custom container control for our ALV Control
create object custom_container1
exporting
container_name = cont_on_main
exceptions
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
if sy-subrc ne 0.
add your handling, for example
call function 'POPUP_TO_INFORM'
exporting
titel = g_repid
txt2 = sy-subrc
txt1 = 'The control could not be created'(001).
endif.
create an instance of alv control
create object grid1
exporting i_parent = custom_container1.
allow to select single lines - Multilines = A
gs_layout1-sel_mode = 'B'.
t_out[] = t_out_mat[].
gt_fieldcat1[] = gt_fieldcat[].
ZSTRUCT needs to be a structure or table in the data dictionary.
The data elements are used for the column headings of your table control.
T_OUT is your table for data.
call method grid1->set_table_for_first_display
exporting i_structure_name = 'ZSTRUCT'
is_layout = gs_layout1
changing it_outtab = t_out.
->Create Object to receive events and link them to handler methods.
When the ALV Control raises the event for the specified instance
the corresponding method is automatically called.
*
create object event_receiver.
set handler event_receiver->handle_user_command for grid1.
set handler event_receiver->handle_toolbar for grid1.
§ 4.Call method 'set_toolbar_interactive' to raise event TOOLBAR.
call method grid1->set_toolbar_interactive.
endif.
call method cl_gui_control=>set_focus exporting control = grid1.
endmodule. " create_container OUTPUT
<REMOVED BY MODERATOR>
Cheers,
Chandra Sekhar.
Edited by: Alvaro Tejada Galindo on Jul 25, 2008 10:43 AM
2016 Aug 04 8:33 AM
2008 Feb 07 10:11 AM
Hi
In order to add user command functioality to the ALV grid you need to perform the following steps:
1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include 'USER_COMMAND' FORM
2. Create 'USER_COMMAND' FORM
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
I_callback_user_command = 'USER_COMMAND' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
----
FORM USER_COMMAND *
----
--> R_UCOMM *
--> RS_SELFIELD *
----
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
Check function code
CASE r_ucomm.
WHEN '&IC1'.
Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'EBELN'.
Read data table, using index of row user clicked on
READ TABLE it_ekko INTO wa_ekko INDEX rs_selfield-tabindex.
Set parameter ID for transaction screen field
SET PARAMETER ID 'BES' FIELD wa_ekko-ebeln.
Sxecute transaction ME23N, and skip initial data entry screen
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDCASE.
ENDFORM.
Add User command functionality to ALVgrid report
In order modify PF_STATUS of ALV grid report you need to perform the following steps:
1. Update 'REUSE_ALV_GRID_DISPLAY' FM call to include:
i_callback_pf_status_set = 'SET_PF_STATUS' statement.
2. Create 'SET_PF_STATUS' FORM
3. Create pf_status (i.e. 'ZNEWSTATUS').
- It is recommend that you copy standard status'STANDARD' from function group SALV
and modify it accordingly. ALV standard function codes always start with '&'.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE'
i_callback_pf_status_set = 'SET_PF_STATUS' "see FORM
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
i_save = 'X'
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
----
FORM SET_PF_STATUS *
----
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZNEWSTATUS'.
"Copy of 'STANDARD' pf_status from fgroup SALV
ENDFORM.
2008 Feb 07 10:12 AM
Hi,
Please copy the above mentioned PF status to a custom PF status from transaction SE41.
Say your program name is ZPROGRAM and new PF status is ZSTATUS.
Now using SE41 copy the standard ALV pf status to custom PF status.
Then add your button to the PF status - ZSTATUS.
Now in your program ZPROGRAM , create a subroutine:
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTATUS' EXCLUSING rt_Extab.
ENDFORM.
And pass the following to the parameters of ALV:
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'. "Subroutine name
I_CALLBACK_PROGRAM
= 'ZPROGRAM' "your program name.
Cheers,
Aditya
2008 Feb 07 10:12 AM
hi,
first u need to copy standard toolbar of a;v into ztoolbar of ur program....
for this do like this
go to se41.
now go to copy status button
in from write
program SAPLKKBL
status STANDARD_FULLSCREEN
in to write
program ZALV_DS
status ZSTAT
now add ur needed buttons and activate that status (zstat) .
now write this in ur program...
FORM display_data.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'ZALV_DS'
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_STAT'
is_layout = st_layout
i_save = 'X'
it_fieldcat = t_fcat
it_events = t_eve
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.
ENDFORM. "display_data
FORM set_stat USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTAT' EXCLUDING rt_extab.
ENDFORM. "SET_STAT
FORM user_command USING u_comm LIKE sy-ucomm sel_fld TYPE slis_selfield.
CASE u_comm.
WHEN 'TEST'.
CALL TRANSACTION 'MM03'.
ENDCASE.
ENDFORM. "user_command
<REMOVED BY MODERATOR>
Edited by: Alvaro Tejada Galindo on Jul 25, 2008 10:43 AM
2008 Feb 07 10:27 AM
Hi Harini,
U can do this way also.I think it is the simplest way.
for this the pre-requisite is that u create ur own GUI status in ur program using SET PF-STATUS '----
'.
now give that program name and pf status name while u r copying that
standard status ie.,of ALV grid
Go to transaction SE41 (Menu painter).
In the initial screen give the program name SAPLKKBL
In the status give STANDARD
Then go to the menu bar.in that follow this menu
User Interface>Copy->Status.
Then a pop up will appear to give ur program name and the status name.
<REMOVED BY MODERATOR>
Regards,
Chaitanya.
Edited by: Alvaro Tejada Galindo on Jul 25, 2008 10:53 AM