Application Development and Automation 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: 
Read only

Push Button in ALV grid

Former Member
0 Likes
1,337

Hi All,

I need to generate an ALV (grid) report in which I need to create a push button on the tool bar. When I click on this Push button some action needs to be triggered. Any body please tell me how to create the button and also how to cpture the event while clicking on the button. I am not using OOPs concept in my report.

Thanks & Regards,

Neethu.

Hi All,

I need to generate an ALV (grid) report in which I need to create a push button on the tool bar. When I click on this Push button some action needs to be triggered. Any body please tell me how to create the button and also how to cpture the event while clicking on the button. I am not using OOPs concept in my report.

Thanks & Regards,

Neethu.

3 REPLIES 3
Read only

Former Member
0 Likes
616

Hi Neethu,

For this requirement, you have to copy the standard PF status of the ALV output. Do as below :-

1) Go to SE41

2) Enter the program name as SAPLKKBL

3) In the field status enter STANDARD_FULLSCREEN

4) Click on STATUS button on the application toolbar.

5) Enter the name of your Program & a new status name.

6) Click on COPY.

This way the standard status will be copied to the custom status & call the same status in your program using SET PF STATUS statement. Then double click on the custom status name & you will be navigated to SE41, there you can add you new button on the application tool bar & assign a function code, which you can program by enabling the export parameter I_CALLBACK_USER_COMMAND of the Function module REUSE_ALV_GRID_DISPLAY.

Just a sample code snippet for your reference :-

FORM USER_COMMAND USING L_UCOMM LIKE SY-UCOMM
LS_SELFIELD TYPE SLIS_SELFIELD.
CASE L_UCOMM.
WHEN 'your function code goes here'.
Do further processing.

This way you will have the standard PF status alongwith your button as well.

Regards

Abhii

Edited by: Abhii on Nov 30, 2009 10:12 AM

Read only

Former Member
0 Likes
616

Hi,

One of the way would be to goto to SE80 and open the program : "BCALV_TEST_GRID_LAYOUT"

The copy the GUI Status "STANDARD" to ZSTANDARD and the target program will be your Z Report Program.

Now open your progeam in SE80 and and in the application tool bar, remove any unwanted button and add your own button there.

This will get a button on the screen along with all other standard tool bar options.

The action could be trapped on Sy-UCOMM case in your program.

Hope this helps.

Read only

Former Member
0 Likes
616

To add a push button use following steps:

Add push button in the tool bar

Trigger subroutine when push button is clicked

execute the code



CLASS cl_event_receiver 
DEFINITION.
PUBLIC SECTION.   
DATA: ucomm TYPE sy-ucomm.
*   toolbar
METHODS handle_toolbar_set     
FOR EVENT toolbar OF cl_gui_alv_grid     
IMPORTING e_object e_interactive.

*   user command
METHODS handle_user_command     
FOR EVENT user_command OF cl_gui_alv_grid     
IMPORTING e_ucomm.

CLASS cl_event_receiver IMPLEMENTATION.
METHOD handle_user_command.   
CASE e_ucomm.    
WHEN text-022.       

PERFORM upload_id.     
WHEN OTHERS.   ENDCASE. 
ENDMETHOD.    
METHOD handle_toolbar_set.
* append a separator to normal toolbar   
CLEAR ls_toolbar.   
MOVE 3 TO ls_toolbar-butn_type.   
APPEND ls_toolbar TO e_object->mt_toolbar.
CLEAR ls_toolbar.   
MOVE :text-033 TO ls_toolbar-function,
*" function code of the push button         
text-033 TO ls_toolbar-text.
*"text that will be displayed on the push button   
APPEND ls_toolbar    TO e_object->mt_toolbar.
ENDMETHOD.ENDCLASS.
*set even handlers
SET HANDLER event_receiver1->handle_toolbar_set  FOR g_grid1. 
SET HANDLER event_receiver1->handle_user_command FOR g_grid1.