2013 Dec 09 9:24 PM
Hello
I created an ALV Grid program and added a custom button in the Application Toolbar. When I press the button everything works great, but after pressing the button then pressing ENTER key the code for the custom button is triggered again. It seems focus is still on the button from pressing it the first time. Is there a way to set focus off the Application Tool bar or disabling the ENTER Key?.
Thanks
2013 Dec 09 9:31 PM
Hi Gary,
Be sure before the finish your action clear sy-ucomm.
It´s better handle this defining ok_code varible.
i.e.
ok_code = sy-ucomm.
case ok_code.
when 'ENTER'.
*-- Your code here --*
clear ok_code.
when 'BACK'
*-- Your code here --*
clear ok_code.
endcase.
Regadrs,
2013 Dec 09 9:31 PM
Hi Gary,
Be sure before the finish your action clear sy-ucomm.
It´s better handle this defining ok_code varible.
i.e.
ok_code = sy-ucomm.
case ok_code.
when 'ENTER'.
*-- Your code here --*
clear ok_code.
when 'BACK'
*-- Your code here --*
clear ok_code.
endcase.
Regadrs,
2013 Dec 09 9:54 PM
Hello,
Please check your button function code (Ok_code). I think you need to change your function code or you can clear your function code.
Thanks & Regards,
Abhijit
2013 Dec 09 10:06 PM
Hi,
We cannot disable enter key.To know about enter key go through Reading Function Codes (SAP Library - SAP NetWeaver by Key Capability).Soyou can solve your problem in 2 ways
1.You can assign some function code to ENTER in gui status
2.As suggested by David.
Regards,
Sreenivas.
2013 Dec 10 4:06 AM
Hi,
Enter key dont have a sy-ucomm value. You want to manually set the ENTER Key sy-ucomm value.
In PFSTATUS set enter key valus as shown below.
Save it and activate it. I think this may help you...
Also check the ok_code ..... clear it properly.
Regards,
Alenlee MJ
2013 Dec 10 4:19 AM
2013 Dec 10 4:20 AM
HI Gary Morman
Debug or share code what you written code for custom button in the Application Toolbar.
2013 Dec 10 4:26 PM
Still have focus on button after pressing it and then pressing ENTER executes same code as was done by pressing the button. Below is what I did maybe that will help?
I copied the GUI Status (STANDARD) from an existing SAP Program using SE41 to my program and then added a button to Application Toolbar.
I call the ALV GRID (below is sample of my code)
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = sy-repid
is_layout = gs_layout
i_callback_user_command = 'USER_COMMAND'
i_callback_pf_status_set = 'SET_PF_STATUS'
it_fieldcat = gt_fc
it_sort = gt_sort
i_save = 'A'
is_variant = g_variant
it_events = gt_events
is_print = gs_print
i_bypassing_buffer = 'X'
TABLES
t_outtab = gt_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
FORM user_command USING r_ucomm LIKE sy-ucomm "#EC CALLED
rs_selfield TYPE slis_selfield.
DATA: l_okcode LIKE sy-ucomm.
l_okcode = r_ucomm.
CLEAR r_ucomm.
CASE rs_selfield-fieldname.
WHEN 'MATNR'.
SET PARAMETER ID 'MAT' FIELD rs_selfield-value.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
EXIT.
ENDCASE.
IF g_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = g_grid.
ENDIF.
*Check if any data entered in alv Grid
CALL METHOD g_grid->check_changed_data.
CASE l_okcode.
WHEN '&DATA_SAVE'.
PERFORM button_sort.
PERFORM button_print.
LEAVE TO SCREEN 0.
WHEN 'SORT'.
PERFORM button_sort.
WHEN 'SELECT'.
PERFORM button_select.
ENDCASE.
*Refresh to make sure all entries valid
CALL METHOD g_grid->refresh_table_display.
2013 Dec 10 5:14 PM
2013 Dec 10 8:52 PM
Is this what you need
FORM user_command USING r_ucomm LIKE sy-ucomm "#EC CALLED
rs_selfield TYPE slis_selfield.
DATA: l_okcode LIKE sy-ucomm.
l_okcode = r_ucomm.
CLEAR r_ucomm.
CASE rs_selfield-fieldname.
WHEN 'MATNR'.
SET PARAMETER ID 'MAT' FIELD rs_selfield-value.
CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.
EXIT.
ENDCASE.
IF g_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = g_grid.
ENDIF.
*Check if any data entered in alv Grid
CALL METHOD g_grid->check_changed_data.
CASE l_okcode.
WHEN '&DATA_SAVE'.
PERFORM button_sort.
PERFORM button_print.
LEAVE TO SCREEN 0.
WHEN 'SORT'.
PERFORM button_sort.
WHEN 'SELECT'.
PERFORM button_select.
ENDCASE.
*Refresh to make sure all entries valid
CALL METHOD g_grid->refresh_table_display.
2013 Dec 11 4:18 AM
Hi Gary,
Everything seems to be right in your code. I think you should clear field "L_OKCODE" everytime after you are done with your event handling. Below code might help.
CASE l_okcode.
WHEN '&DATA_SAVE'.
(your subroutines )
CLEAR l_okcode.
WHEN 'SORT'.
(your subroutines )
CLEAR l_okcode.
WHEN 'SELECT'.
(your subroutines )
CLEAR l_okcode.
ENDCASE.
Regards,
Ramiz