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

button_click(ooalv)

Former Member
0 Likes
1,112

Hi

How to handle button_click event in ooalv..tell me the procedure..

regards

sravani

Hi

How to handle button_click event in ooalv..tell me the procedure..

regards

sravani

5 REPLIES 5
Read only

Former Member
0 Likes
895

Hi Sravani,

Go through this link.

[Interactive ALV Using OOP's|http://saptechnical.com/Tutorials/ALV/Interactive/oops.htm]

if found helpfull do Reward.

Eshwar

Read only

Former Member
0 Likes
895

HI,

Take help of this.

methods: button_click for event button_click of

cl_gui_alv_grid importing es_col_id

es_row_no.

write this

in implementation

METHOD button_click.

DATA: message TYPE string.

DATA: row_c(4) TYPE c.

DATA: row TYPE i.

DATA column TYPE lvc_s_col.

*row_c = ES_ROW_NO.

row = es_row_no-row_id.

*concatenate 'ROW' row_c 'COLUMN' column

  • into message separated by space.

IF es_col_id = 'TEXT'.

  • set parameter id: 'AUN' field k_vbeln.

READ TABLE it_final INTO wa_final INDEX row.

wa_text-client = '100'.

wa_text-vbeln = wa_final-vbeln.

wa_text-posnr = wa_final-posnr.

wa_text-vbeln_del = wa_final-vbeln1.

wa_text-posnr_del = wa_final-posnr1.

wa_text-etenr = wa_final-etenr.

wa_text-user_name = sy-uname.

wa_text_dummy = wa_text.

if wa_text-vbeln_del = ' '.

wa_text-vbeln_del = '0000000000'.

endif.

CALL SCREEN 2000.

ENDIF.

reward if helpful,

kushagra

Read only

Former Member
0 Likes
895

hii,

in object oriented alv there is a method defined in the main class

cl_gui_alv_grid as double click.

to implement it you must define a method in the definition part of the class like

public: methods:m1 for event double_click of cl_gui_alv_grid importing e_row.

here we define the methodwith 1 of the importing parameters.

then in the implementation part we can implement the method with e_row_rowtype as the parameter.

hopefully i could help u.

reward if helpful.

thanksssss

Read only

Former Member
0 Likes
895

hi,

in alv grid control we can handle event handler method...

button_click-Query a click on a pushbutton in the ALV Grid Control.

after user has clicked a push button in the alv grid control you handle this event in the event handler method...

Here is a sample code to illustrate a general scheme for our local class.

CLASS lcl_event_handler DEFINITION .

PUBLIC SECTION .

METHODS:

*To control button clicks

handle_button_click

FOR EVENT button_click OF cl_gui_alv_grid

IMPORTING e_oject e_ucomm .

ENDCLASS.

CLASS lcl_event_handler IMPLEMENTATION .

*Handle Button Click

METHOD handle_button_click .

PERFORM handle_button_click USING e_object e_ucomm .

ENDMETHOD .

ENDCLASS .

regards,

Ashok reddy

Read only

0 Likes
895

hi use this report and u will get your answer

PROGRAM TEST.

include <color>.

DATA: OK_CODE LIKE SY-UCOMM,

  • GT_SFLIGHT TYPE TABLE OF SFLIGHT,

G_CONTAINER TYPE SCRFNAME VALUE 'BCALV_GRID_DEMO_0100_CONT1',

GRID1 TYPE REF TO CL_GUI_ALV_GRID,

G_CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER.

DATA: GS_LAYOUT TYPE LVC_S_LAYO.

*data: ls_color type lvc_s_scol.

*--- Internal table holding list data

DATA BEGIN OF gt_sflight OCCURS 0 .

INCLUDE STRUCTURE SFLIGHT .

DATA rowcolor(4) TYPE c .

data: edit type lvc_t_edit.

DATA cellcolors TYPE lvc_t_scol .

DATA CELLSTYLES TYPE lvc_t_styl .

DATA END OF gt_sflight .

DATA: ls_cellcolor TYPE lvc_s_scol ,

edit1 type lvc_s_edit,

LS_cellstyles TYPE lvc_S_styl .

----


  • MAIN *

----


***************

**********

SELECT * FROM SFLIGHT INTO corresponding fields of TABLE GT_SFLIGHT.

*loop at gt_sflight into wa_sflight.

    • clear lt_color.

    • clear ls_color.

*

    • wa_sflight-fname = 'CURRENCY'.

  • wa_sflight-col = col_positive.

  • wa_sflight-int = 0.

  • wa_sflight-inv = 0.

    • append ls_color to wa_sflight-lt_color.

*

*modify table gt_sflight from wa_sflight .

*endloop.

READ TABLE gt_sflight INDEX 5 .

gt_sflight-rowcolor = 'C500'.

ls_cellcolor-fname = 'SEATSOCC' .

ls_cellcolor-color-col = '7' .

ls_cellcolor-color-int = '1' .

APPEND ls_cellcolor TO gt_sflight-cellcolors .

gt_sflight-rowcolor = 'C700'.

ls_cellcolor-fname = 'CURRENCY' .

ls_cellcolor-color-col = '7' .

ls_cellcolor-color-int = '1' .

APPEND ls_cellcolor TO gt_sflight-cellcolors .

        • TO MAKE FIELD EDITABLE

edit1-FIELDNAME = 'CURRENCY'.

append edit1 to gt_sflight-edit.

LS_cellstyles-fieldname = 'CURRENCY' .

LS_cellstyles-style = cl_gui_alv_grid=>mc_style_ENABLED .

APPEND LS_cellstyles TO gt_sflight-cellstyles .

MODIFY gt_sflight INDEX 5 .

data: x type i value 1.

loop at gt_sflight to 5.

LS_cellstyles-fieldname = 'PRICE' .

LS_cellstyles-style = cl_gui_alv_grid=>mc_style_button.

APPEND LS_cellstyles TO gt_sflight-cellstyles .

MODIFY gt_sflight INDEX x.

x = x + 1.

endloop.

CALL SCREEN 100.

CLASS lcl_event_handler DEFINITION .

PUBLIC SECTION .

METHODS:

*To control button clicks

handle_button_click

FOR EVENT button_click OF cl_gui_alv_grid

IMPORTING ES_COL_ID ES_ROW_NO .

endclass.

CLASS lcl_event_handler IMPLEMENTATION .

*Handle Button Click

METHOD handle_button_click .

PERFORM handle_button_click USING ES_COL_ID ES_ROW_NO.

ENDMETHOD .

ENDCLASS .

******************

****************

----


  • MODULE PBO OUTPUT *

----


MODULE PBO OUTPUT.

SET PF-STATUS 'MAIN100'.

IF G_CUSTOM_CONTAINER IS INITIAL.

CREATE OBJECT G_CUSTOM_CONTAINER

EXPORTING CONTAINER_NAME = G_CONTAINER.

CREATE OBJECT GRID1

EXPORTING I_PARENT = G_CUSTOM_CONTAINER.

  • Gs_layout-INFO_FNAME = 'ROWCOLOR'.

Gs_layout-CTAB_FNAME = 'CELLCOLORS'.

*Gs_layout-EDIT_MODE = 'X'.

        • TO MAKE A CELL EDITABLE

Gs_layout-STYLEFNAME = 'CELLSTYLES' .

      • END OF CELL EDITABLE

CALL METHOD GRID1->set_ready_for_input

EXPORTING i_ready_for_input = '1'.

CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY

EXPORTING I_STRUCTURE_NAME = 'SFLIGHT'

is_layout = gs_layout

CHANGING IT_OUTTAB = GT_SFLIGHT[].

ENDIF.

DATA gr_event_handler TYPE REF TO lcl_event_handler .

*--Creating an instance for the event handler

CREATE OBJECT gr_event_handler .

*--Registering handler methods to handle ALV Grid events

SET HANDLER gr_event_handler->handle_button_click FOR GRID1 .

ENDMODULE.

----


  • MODULE PAI INPUT *

----


MODULE PAI INPUT.

  • to react on oi_custom_events:

call method cl_gui_cfw=>dispatch.

CASE OK_CODE.

WHEN 'EXIT'.

PERFORM EXIT_PROGRAM.

WHEN OTHERS.

  • do nothing

ENDCASE.

CLEAR OK_CODE.

ENDMODULE.

----


  • FORM EXIT_PROGRAM *

----


FORM EXIT_PROGRAM.

  • CALL METHOD G_CUSTOM_CONTAINER->FREE.

  • CALL METHOD CL_GUI_CFW=>FLUSH.

LEAVE PROGRAM.

ENDFORM.

FORM handle_button_click USING "i_row TYPE lvc_s_row

i_column TYPE lvc_s_col

is_row_no TYPE lvc_s_roid.

READ TABLE gt_sflight INDEX is_row_no-row_id .

IF sy-subrc = 0. "AND i_column-fieldname = 'SEATSOCC' .

*CALL SCREEN 200 . "Details about passenger-seat matching

data: dis type string, rowid(20).

rowid = is_row_no-row_id.

concatenate 'Hi I have done push button in alv hahahaha' i_column rowid into dis separated by space.

message dis type 'I' .

ENDIF .

ENDFORM .

reward if useful