Application Development 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: 

about alv ENTER event

Former Member
0 Kudos

Hi experts:

This is a dialog program,in alv,one list is edited.

If I input the data in some cell,when I press the enter key,I want to output the sum of all the cell in the list.

Thanks all.

dear Wei

1 ACCEPTED SOLUTION

Former Member
0 Kudos

First of all set the enter event as application event so that PAI will be called .

Let me know what is the probelm .

4 REPLIES 4

Former Member
0 Kudos

First of all set the enter event as application event so that PAI will be called .

Let me know what is the probelm .

0 Kudos

thanks a lot.I have solve the ENTER event.

but now I have another problem.

I changed the data in one cell,when I press ENTER,

method check_bcje.

data bcje type ekpo-netwr.

call method pr_data_changed->get_cell_value

exporting

i_row_id = ps_good_bcje-row_id

i_fieldname = ps_good_bcje-fieldname

importing

e_value = bcje.

this method pass the data bcje,the data has changed.

for example,I input 100.00,it changed to 1.00

23.00-->0.23.

do you know why?

thanks!

0 Kudos

yes , this problem occurs when you don't specify the DECIMALS_OUT in the fieldcatalog for the column.

fieldcatalog-decimals_out = 2. "<----give this for the column which you are editing

try to specify the DECIMALS_OUT option and see...?

0 Kudos

I uesed the field reference to a table field,so I have solve the problem.here is all the code I solve this problem.thank you all!

1.定义类

----


  • CLASS lcl_grid_event_receiver DEFINITION

----


CLASS lcl_grid_event_receiver DEFINITION .

PUBLIC SECTION.

METHODS:

  • toolbar

  • FOR EVENT toolbar OF cl_gui_alv_grid

  • IMPORTING e_object e_interactive ,

user_command

FOR EVENT user_command OF cl_gui_alv_grid

IMPORTING e_ucomm ,

handle_data_changed

FOR EVENT data_changed OF cl_gui_alv_grid

IMPORTING er_data_changed.

PRIVATE SECTION.

  • This flag is set if any error occured in one of the

  • following methods:

DATA: error_in_data TYPE c.

METHODS: check_bcje

IMPORTING

ps_good_bcje TYPE lvc_s_modi

pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.

ENDCLASS. "lcl_grid_event_receiver DEFINITION

DATA : grid_handler TYPE REF TO lcl_grid_event_receiver.

2.定义方法

&----


*& Class (Implementation) lcl_grid_event_receiver

&----


  • Text

----


CLASS lcl_grid_event_receiver IMPLEMENTATION.

**----


    • Method to handle user commands from toolbar

**----


METHOD user_command.

CASE e_ucomm .

WHEN ''.

ENDCASE.

ENDMETHOD. "user_command

METHOD handle_data_changed.

DATA: ls_good TYPE lvc_s_modi.

error_in_data = space.

LOOP AT er_data_changed->mt_good_cells INTO ls_good.

CASE ls_good-fieldname.

WHEN 'BCJE'.

CALL METHOD check_bcje

EXPORTING

ps_good_bcje = ls_good

pr_data_changed = er_data_changed.

ENDCASE.

ENDLOOP.

ENDMETHOD. "handle_data_changed

METHOD check_bcje.

DATA bcje TYPE ekpo-netwr.

CALL METHOD pr_data_changed->get_cell_value

EXPORTING

i_row_id = ps_good_bcje-row_id

i_fieldname = ps_good_bcje-fieldname

IMPORTING

e_value = bcje.

break-point.

IF bcje IS NOT INITIAL.

READ TABLE item into type_item1 INDEX ps_good_bcje-row_id.

  • ASSIGN item TO <ls_fieldcat1>.

  • <ls_fieldcat1>-bcje = bcje.

type_item1-bcje = bcje.

MODIFY item from type_item1 INDEX ps_good_bcje-row_id.

CLEAR:item,type_item1.

CALL METHOD alv_grid->refresh_table_display .

ENDIF.

ENDMETHOD. "check_planetype

ENDCLASS. "lcl_grid_event_receiver

3.在build_objects里添加回车事件

IF grid_handler IS INITIAL.

CREATE OBJECT grid_handler.

SET HANDLER:

grid_handler->user_command FOR alv_grid,

grid_handler->handle_data_changed FOR alv_grid."加回车事件

ENDIF.

4.在初始化里加上一下语句

CALL METHOD alv_grid->set_ready_for_input

EXPORTING

i_ready_for_input = 1.

CALL METHOD alv_grid->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_modified.