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 push button functionality

Former Member
0 Likes
679

Hi all,

I have a push button as one of the fields in fieldcatalog.i am using class cl_gui_alv_grid .

I want that when that push button is clicked then some action should take place.

How can i get user action on clicking that Push button.

please reply soon with some sample code

regards,

kushagra

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
437

hi,

check this program.

BCALV_TEST_GRID_EVENTS

use event button_click of cl_gui_alv_grid.

2 REPLIES 2
Read only

Former Member
0 Likes
437

Hi,

Reference:http://www.erpgenie.com/sap/abap/controls/alvgrid.htm

Note that this example uses table ZSFLIGHT. The table is equivalent to the table SFLIGHT.

Steps:

Create an executable program (Report)

Create a screen (100) and place a custom container named ALV_CONTAINER on the screen

Create a Pushbutton. Give it the text Exit and the functioncode EXIT

REPORT sapmz_hf_alv_grid .

TABLES: zsflight.

*----


  • G L O B A L I N T E R N A L T A B L E S

*----


DATA: gi_sflight TYPE STANDARD TABLE OF sflight.

*----


  • G L O B A L D A T A

*----


DATA: ok_code LIKE sy-ucomm,

g_wa_sflight LIKE sflight.

  • Declare reference variables to the ALV grid and the container

DATA:

go_grid TYPE REF TO cl_gui_alv_grid,

go_custom_container TYPE REF TO cl_gui_custom_container.

*----


  • S T A R T - O F - S E L E C T I O N.

*----


START-OF-SELECTION.

SET SCREEN '100'.

&----


*& Module USER_COMMAND_0100 INPUT

&----


MODULE user_command_0100 INPUT.

CASE ok_code.

WHEN 'EXIT'.

LEAVE TO SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

&----


*& Module STATUS_0100 OUTPUT

&----


MODULE status_0100 OUTPUT.

  • Create objects

IF go_custom_container IS INITIAL.

CREATE OBJECT go_custom_container

EXPORTING container_name = 'ALV_CONTAINER'.

CREATE OBJECT go_grid

EXPORTING

i_parent = go_custom_container.

PERFORM load_data_into_grid.

ENDIF.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Form load_data_into_grid

&----


FORM load_data_into_grid.

  • Read data from table SFLIGHT

SELECT *

FROM zsflight

INTO TABLE gi_sflight.

  • Load data into the grid and display them

CALL METHOD go_grid->set_table_for_first_display

EXPORTING i_structure_name = 'SFLIGHT'

CHANGING it_outtab = gi_sflight.

ENDFORM. " load_data_into_grid

Reward points if helpful.

Regards,

Ramya

Read only

Former Member
0 Likes
438

hi,

check this program.

BCALV_TEST_GRID_EVENTS

use event button_click of cl_gui_alv_grid.