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: 

cl_gui_alv_grid --> mc_evt_enter --> alv does not process hole roundtrip

wagener-mark
Contributor
0 Kudos

Hello,

I use the cl_gui_alv_grid and registered on the mc_evt_enter event. I do this to calculat some costs after the user entered some data into the editable colums.

It works almost perfectly. everything what happens within the alv is correct. the problem is that the alv does not process a real roundtrip on this enter event. that means he does not go through the PAI and PBO modules, so i cannot refresh data on my dynpro.

when i set the cursor somewhere to the dynpro and process enter everything is fine. my dynpro fields are refresh and i am happy

does anybody have the same problem? why doesn't the alv process a real roundtrip?

kind regards!

FIELD-SYMBOLS: <wa_alv_fieldcat> LIKE LINE OF  g_t_alv_fieldcat.

  CLEAR g_t_alv_fieldcat.

*** Objekte erzeugen:

  CREATE OBJECT g_o_cc_alv
    EXPORTING
      container_name = 'CC_ALV'.

  CREATE OBJECT g_o_alv_grid
    EXPORTING
      i_parent = g_o_cc_alv.


*** Feldkatalog setzen:
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
   EXPORTING
*     I_BUFFER_ACTIVE              =
     i_structure_name             = '/CIBD/RV02_POS_DATEN_WE'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_BYPASSING_BUFFER           =
*     I_INTERNAL_TABNAME           =
    CHANGING
      ct_fieldcat                  = g_t_alv_fieldcat
   EXCEPTIONS
     inconsistent_interface       = 1
     program_error                = 2
     OTHERS                       = 3.

*** Alle Felder editierbar machen                                          
  LOOP AT g_t_alv_fieldcat ASSIGNING <wa_alv_fieldcat>.
    <wa_alv_fieldcat>-edit = 'X'.
  ENDLOOP.

*** Edit Event registrieren:                                               
  g_o_alv_grid->register_edit_event(
  EXPORTING
    i_event_id = g_o_alv_grid->mc_evt_enter ).

*** ...und EventHandler zuweisen
  CREATE OBJECT g_o_alv_events.
  SET HANDLER g_o_alv_events->handle_data_changed FOR g_o_alv_grid.

*** ALV editierbar machen:                                                  
  g_o_alv_grid->set_ready_for_input(
  EXPORTING
    i_ready_for_input = 1 ).

*** ALV Grid anzeigen:
  g_o_alv_grid->set_table_for_first_display(
  EXPORTING
    i_structure_name     = '/cibd/rv02_pos_daten_we'
    is_layout            = g_alv_layout
    it_toolbar_excluding = g_t_alv_auszubl_icons
  CHANGING
    it_outtab            = g_t_daten[]
    it_fieldcatalog      = g_t_alv_fieldcat ).

*** Fokus auf das Grid setzen
  CALL METHOD cl_gui_alv_grid=>set_focus
    EXPORTING
      control           = g_o_alv_grid
    EXCEPTIONS
      cntl_error        = 1
      cntl_system_error = 2
      OTHERS            = 3.

*** Flush
  CALL METHOD cl_gui_cfw=>flush.

*----------------------------------------------------------------------*
*       CLASS lcl_events DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_events DEFINITION.

  PUBLIC SECTION.
    METHODS:
      handle_data_changed
            FOR EVENT data_changed  OF  cl_gui_alv_grid
            IMPORTING er_data_changed sender.

ENDCLASS.                    "lcl_events DEFINITION

*---------------------------------------------------------------------*
*       CLASS lcl_rohr_eventhandler IMPLEMENTATION
*---------------------------------------------------------------------*
CLASS lcl_events IMPLEMENTATION.

  METHOD handle_data_changed.
******************************************
*** HandleDataChanged                  ***
******************************************
    DATA: ls_good                TYPE lvc_s_modi.
    DATA: dez_zahl TYPE p LENGTH 13 DECIMALS 10.
    DATA kostensatz TYPE dmbtr.
    FIELD-SYMBOLS: <wa_daten> LIKE LINE OF g_t_daten.


    ASSIGN g_t_daten TO <g_itab>.

    "HINWEIS: Variante mit Loop ... Endloop implementiert, da Aufruf von
    "g_o_alv_grid->check_changed_data( ) nicht funktioniert innerhalb des
    "ALV.

*** alle Inhalte der geänderten Zellen in die interne Tabelle schreiben
    LOOP AT er_data_changed->mt_good_cells INTO ls_good.
*** Dazu auf die richtige Zeile in der ITAB positionieren:
      READ TABLE <g_itab> ASSIGNING <g_wa> INDEX ls_good-row_id.
      IF sy-subrc = 0.
*** Und das geänderte Feld dem Feldsymbol zuweisen
        ASSIGN COMPONENT ls_good-fieldname OF STRUCTURE <g_wa> TO <g_feld>.
        IF sy-subrc = 0.
*** Feldwert zuweisen
          <g_feld> = ls_good-value.
        ENDIF.
      ENDIF.
    ENDLOOP.

*** ALV refreshen
    PERFORM alv_refresh. "here i calculate the costs
*** Und neu ausgeben
    g_o_alv_grid->refresh_table_display( ).

  ENDMETHOD.                    "handle_data_changed

ENDCLASS.                    "lcl_events IMPLEMENTATION

2 REPLIES 2

Former Member
0 Kudos

Did you ever figure out how to make your ALV OO event trigger your dynpro PAI?

peter_langner
Active Contributor
0 Kudos

Hi,

if you want to pass back the value of the field you just checked, you must use the method er_data_changed->modify_cell( ... ).


If you have other fields of the table line which you want to update, you can force the system to issue a PAI event by calling the method cl_gui_cfw=>set_new_ok_code( 'ENTER' ). "ENTER" is a dummy okcode, which does nothing in my application. You can pass any okcode you like.


See also: set_new_ok_code - ALV Grid Control - SAP Library


Peter