2011 Jul 21 11:26 AM
Hello Experts
I want to add Some custom buttons on my ALV Toolbar with caption 'SAVE' and 'CHECK'. Suggest the best possible way for this.
Thanks in advance
Gaurav
2011 Jul 21 11:32 AM
Hello Experts
I want to add Some custom buttons on my ALV Toolbar with caption 'SAVE' and 'CHECK'. Suggest the best possible way for this.
Thanks in advance
Gaurav
2011 Jul 21 11:32 AM
2011 Jul 21 11:32 AM
pls create the gui status ,then u can customize the buttons.
tks. best regards.
2011 Jul 21 11:34 AM
OPEN tcode se80 and select function group and open SALV
open gui status and right click on standard and copy it to your required program
and add your required two buttons wit your desired names.
and use the below sample code in your program.
FORM pf_status_set USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STATUS1' .
ENDFORM. "PF_STATUS_SET
Pass this form name to your ALV FM.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = g_repid
i_callback_pf_status_set = 'PF_STATUS_SET'
i_callback_user_command = 'USER_COMMAND'
is_layout = i_layout
it_fieldcat = i_fieldcat[]
TABLES
t_outtab = p_out
EXCEPTIONS
program_error = 1
OTHERS = 2.
2011 Jul 21 11:45 AM
hi,
you need to create a gui_status.
Add these two buttons and assign a func code to them.
in your program at user command event check the value of sy-ucomm.And assign the desired processing.
2011 Jul 21 11:48 AM
Use Events TOOLBAR and USER_COMMAND of class CL_GUI_ALV_GRID
TOOLBAR -> to add your buttons into e_object->mt_toolbar (ALV Toolbar)
USER_COMMAND -> To handle the actions to be done on press of these buttons.
Regards,
Seema
2011 Jul 21 12:00 PM
Hi ,
If you are using CL_GUI_ALV_GRID then
1) Create an event handler class.
2) Handle events TOOLBAR and USER_COMMAND of class CL_GUI_ALV_GRID.
3) In method of event TOOLBAR use structure STB_BUTTON to fill your toolbar button details like Fcode, text Icon
append this structure to E_OBJECT->MT_TOOLBAR .
4) In USER COMMAND write your code for the buttons
5) Set event handler after method SET_TABLE_FOR_FIRST_DISPLAY
Check the code below
CLASS CL_EVENT_HANDLER DEFINITION.
PUBLIC SECTION.
METHODS : USER_COMMAND FOR EVENT AFTER_USER_COMMAND OF CL_GUI_ALV_GRID IMPORTING E_UCOMM,
TOOLBAR FOR EVENT TOOLBAR OF CL_GUI_ALV_GRID IMPORTING E_OBJECT E_INTERACTIVE.
ENDCLASS.
CLASS CL_EVENT_HANDLER IMPLEMENTATION.
METHOD TOOLBAR.
DATA : MT_TOOLBAR TYPE STB_BUTTON.
CLEAR MT_TOOLBAR.
MT_TOOLBAR-BUTN_TYPE = '3'. "separator
APPEND MT_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
CLEAR MT_TOOLBAR.
MT_TOOLBAR-BUTN_TYPE = '0'. "normal Button
MT_TOOLBAR-FUNCTION = 'CL_REF'. "fcode
MT_TOOLBAR-ICON = '@42@'.
MT_TOOLBAR-QUICKINFO = 'UPDATE LOG FILE'.
APPEND MT_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
ENDMETHOD. "TOOLBAR
METHOD USER_COMMAND.
IF E_UCOMM = 'CL_REF'.
PERFORM ACTION.
ENDIF.
ENDMETHOD. "USER_COMMAND
ENDCLASS.
Thanks,
Anmol Bhat.
2015 Apr 23 4:49 PM
Hello,
Thank you for your answer Anmol. I've used your code to show an information message when I click on the button, and after I want it to open another screen using : "CALL SCREEN 101" on the ACTION FORM, so I created the screen 101, but actually when I click on the button the current screen still show in up and hiding the new one. I'm wondering if we can do it with this solution or we can't do that way.
Thank you.
Youssef
2011 Jul 21 2:59 PM
Hi
I have got the buttons now. Now I have created a sub-routine and I am writing some code for user-command. Same Sub-routine I have passed to the REUSE_ALV_GRID_DISPLAY FM to the appropriate field. But still the click on button is not getting captured. Plz help.
Thanks
Gaurav
2011 Jul 21 3:21 PM
if you want the button to take effect then you need you write your code in this way
at user-command.
case sy-ucomm.
when 'Your button name here'.
your code.
when 'your second button'.
you code.
endcase.
endat.
please visit this video for clear idea [click here|http://www.youtube.com/watch?v=z5OAW1btigQ]
2011 Jul 21 3:35 PM
2015 Jan 23 9:29 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |