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

ALV GRID CUSTOM BUTTONS IN APPLICATION TOOLBAR

Former Member
0 Likes
2,691

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

1 ACCEPTED SOLUTION
Read only

former_member235395
Contributor
0 Likes
2,308

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, 

10 REPLIES 10
Read only

former_member235395
Contributor
0 Likes
2,309

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, 

Read only

Abhijit74
Active Contributor
0 Likes
2,308

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

Read only

former_member219762
Contributor
0 Likes
2,308

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.

Read only

Former Member
0 Likes
2,308

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

Read only

venkat_aileni
Contributor
0 Likes
2,308

Please clear your OK_CODE.

-Venkat

Read only

former_member209120
Active Contributor
0 Likes
2,308

HI  Gary Morman

Debug or share code what you written code for custom button in the Application Toolbar.

Read only

0 Likes
2,308

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.


Read only

0 Likes
2,308

Hi

Read only

0 Likes
2,308

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.

Read only

0 Likes
2,308

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