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

how to assign a function code to push button - cell in ALV Grid?

Former Member
0 Likes
1,755

A push button has been assigned to a cell in alv grid.

How to assign a function code to this button and call it in the program?

Thanks,

Ven

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
993

http://help.sap.com/saphelp_erp2004/helpdata/en/88/387f380c2f2e3ce10000009b38f8cf/content.htm.

Try,

    • set icon fields for all fields that contains the ICON in their name!

CLEAR ls_fcat.

ls_fcat-icon = c_checked.

ls_fcat-edit = 'X'.

ls_fcat-style = ls_fcat-style bit-xor

cl_gui_alv_grid=>MC_STYLE_BUTTON bit-xor

cl_gui_alv_grid=>MC_STYLE_ENABLEd.

MODIFY exi_fieldcat FROM ls_fcat TRANSPORTING icon

WHERE fieldname CS 'ICON'.

OR

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-024.

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-032 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.

A push button has been assigned to a cell in alv grid.

How to assign a function code to this button and call it in the program?

Thanks,

Ven

5 REPLIES 5
Read only

Former Member
0 Likes
993

Hi,

There will be a Function Code assigned to the PushButton.

Trap the Function Code in the SY-UCOMM in Exit Subroutine "USER_COMMAND", and put your code inside that.

Read only

Former Member
0 Likes
994

http://help.sap.com/saphelp_erp2004/helpdata/en/88/387f380c2f2e3ce10000009b38f8cf/content.htm.

Try,

    • set icon fields for all fields that contains the ICON in their name!

CLEAR ls_fcat.

ls_fcat-icon = c_checked.

ls_fcat-edit = 'X'.

ls_fcat-style = ls_fcat-style bit-xor

cl_gui_alv_grid=>MC_STYLE_BUTTON bit-xor

cl_gui_alv_grid=>MC_STYLE_ENABLEd.

MODIFY exi_fieldcat FROM ls_fcat TRANSPORTING icon

WHERE fieldname CS 'ICON'.

OR

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-024.

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-032 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.

Read only

0 Likes
993

I am trying to use teh hotspot from the output of REUSE_ALV_GRID_DISPLAY_LVC. I tried the above suggestions, but I am getting a short dump for the set handler part - saying that the handler can not be null.

Not sure what went wrong??

Read only

Former Member
0 Likes
993

BCALV_VERIFY_DATATYPES has a very good reference. used parts of the code and solved my issue