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: 

REUSE_ALV_GRID_DISPLAY_LVC click enter does not call i_callback_user_command.

ronaldo_aparecido
Contributor
0 Kudos

Hi community

I want to know if is possible call my perfom associated to i_callback_user_command when i Click Enter or if is possible to associate an event to a editable field alv and when click on it then call my perfom associated to i_callback_user_command

Thanks

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos

It's possible only by using the underlying class CL_GUI_ALV_GRID.

ronaldo_aparecido
Contributor
0 Kudos

sandra.rossi thanks it worked fine but now i have a problem because i created a method handle_data_changed and inside this method if my field has a invalid value then is added error to CALL METHOD pr_data_changed->add_protocol_entry and showed by CALL METHOD er_data_changed->display_protocol.

My problem is:I have a Z button in my toolbar and when i click on it after input data in my editable alv field my perform 'USER_COMMAND' is called ( i_callback_user_command = 'USER_COMMAND') and i need to call CALL METHOD gcl_grid->check_changed_data and when it is called the method handle_data_changed is called and it worked correctly but the screen data is not updated, only when an error ocurrs.

It is possible to update the screen data even if an error occurs when passing through the handle_data_changed method ?

the code is attached

report-zrfi.txt

Thanks

Sandra_Rossi
Active Contributor
0 Kudos

Maybe it's the same big question for you, how to make your program work as you expect, but for all other people around here, it's a different question.

You'd better ask another one so that everybody is aware of that new question. I don't exactly understand your question too.

Mixing REUSE_ALV_GRID_DISPLAY and CL_GUI_ALV_GRID is definitely not a good idea. If you use only CL_GUI_ALV_GRID, you could post a minimal reproducible example so that people can better understand by debugging, i.e. adapt this program to your needs:

REPORT zzsro_test5 LINE-SIZE 300.
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS on_user_command FOR EVENT user_command OF cl_gui_alv_grid importing e_ucomm.
    METHODS on_data_changed FOR EVENT data_changed OF cl_gui_alv_grid importing er_data_changed e_ucomm.
    METHODS handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid IMPORTING e_object e_interactive.
ENDCLASS.

DATA int_fleet TYPE TABLE OF sflight.
DATA alv_1 TYPE REF TO cl_gui_alv_grid.
DATA event_receiver TYPE REF TO lcl_event_receiver.

PARAMETERS dummy.

AT SELECTION-SCREEN OUTPUT.
  IF alv_1 IS INITIAL.
    SELECT * FROM sflight INTO TABLE int_fleet.
    CREATE OBJECT alv_1 EXPORTING i_parent = cl_gui_container=>screen0.
    CREATE OBJECT event_receiver.
    SET HANDLER event_receiver->handle_toolbar FOR alv_1.
    SET HANDLER event_receiver->on_user_command FOR alv_1.
    SET HANDLER event_receiver->on_data_changed FOR alv_1.
    alv_1->register_edit_event( i_event_id = alv_1->mc_evt_enter ).
    CALL METHOD alv_1->set_table_for_first_display
      EXPORTING
        is_layout                     = value #( edit = abap_true )
        i_structure_name              = 'SFLIGHT'
      CHANGING
        it_outtab                     = int_fleet
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
  ENDIF.

CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD handle_toolbar.
    APPEND VALUE #( function = 'Z' text = 'Test' ) TO e_object->mt_toolbar.
  ENDMETHOD.
  METHOD on_user_command.
    if e_ucomm = 'Z'.
      alv_1->check_changed_data( ).
    endif.
  ENDMETHOD.
  METHOD on_data_changed.
  ENDMETHOD.
ENDCLASS.

Sandra_Rossi
Active Contributor
0 Kudos

Just to say, your program is 1000 lines long, it doesn't compile, so it will take me too long to fix it and look at it. I prefer one example program 50 lines long which compiles.