简体   繁体   中英

CL_GUI_ALV_GRID editable field not refresh

I have an ALV grid with an editable field, if I check the data entered and display errors, the ALV updates, if I try to change the input data, other times the ALV does not update anymore.

The code in the PAI is:

    ls_layout-cwidth_opt = abap_true.  
    CREATE OBJECT go_alv     
     EXPORTING
      i_parent          = cl_gui_custom_container=>screen0
    EXCEPTIONS
      error_cntl_create = 1
      error_cntl_init   = 2
      error_cntl_link   = 3
      error_dp_create   = 4
      OTHERS            = 5. 

        IF sy-subrc EQ 0.
    
    *   Adapting field catalog
        CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
          EXPORTING
            i_structure_name       = 'ZAMOUNT'
          CHANGING
            ct_fieldcat            = lt_fieldcat.
        IF sy-subrc EQ 0. 
  *     Field catalog specifics       
        LOOP AT lt_fieldcat ASSIGNING <ls_fieldcat>. 
              IF  <ls_fieldcat>-fieldname = 'DMBTR'.
                <ls_fieldcat>-edit = abap_true.
              ENDIF.
    
          ENDLOOP.
        ENDIF.

    *   Show data usig ALV class
        go_alv->set_table_for_first_display(
                  EXPORTING
                    is_layout       = ls_layout
                  CHANGING
                    it_outtab       = gt_out
                    it_fieldcatalog = lt_fieldcat ).
    
          go_alv->set_ready_for_input( EXPORTING
            i_ready_for_input = 1 ).
    
          CALL METHOD go_alv->register_edit_event
            EXPORTING
              i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    
          CALL METHOD go_alv->register_edit_event
            EXPORTING
              i_event_id = cl_gui_alv_grid=>mc_evt_modified.
      ENDIF.

The code in the PBO is:

        IF go_alv IS NOT INITIAL.

        CALL METHOD go_alv->check_changed_data( ).

        PERFORM check_amounts   TABLES gt_out
                              CHANGING gv_sum_amounts
                                       gv_tot_amount.

       
        CALL METHOD go_alv->refresh_table_display
          EXPORTING
            is_stable      = VALUE #( row = abap_true
                                      col = abap_true )
            i_soft_refresh = 'X'.           
            cl_gui_cfw=>flush( ).

    ENDIF.

In the perform check_amounts I populate a field of the ALV with the errors, if the user modifies the input field and the error is removed in the internal table but it is not shown in the ALV.

I also tried to implement the data_change_finished method by calling the refresh inside but I have not solved the anomaly.

Can you help me? Thanks

I'm not quite sure if I understand your problem but here are some potential issues I see:

  1. You have your validity checks split up. On the one hand there is the data_changed event. On the other hand you have the check_amounts perform.
  • If the data_changed event finds an input error, it'll show you the red outline on your grid. In your internal table ("gt_out") this field will stay the same as before (it'll not update the table with the invalid input.). This might be why you think there should be a message in your grid but there isn't.
  1. Did you define your own local version for the data_changed event? Than the handlers are missing. When you tried doing the refresh in the data_changed_finished event you definitly need the handler for that.
  • Also you said that you only put the refresh in the method for data_changed_finished. You need to put the check_amount perform there too then. Otherwise you called the refresh to early.
  • In the method for data_changed_finished you have the automatically updated table ("gt_out") from the data_changed method. You should be able to update it here and send it to your grid with a refresh.
  1. I don't like that you call the check_changed_data method in your PBO. Because of the register_edit_event calls the data_changed event already triggers when you hit enter or jump to the next field. You usually only call this method when you received a seperat user command, that can be fired before the event can be triggered to be sure that you have correct data.
  • Not 100% sure about this but for your register_edit_event calls, the event id cl_gui_alv_grid=>mc_evt_modified should include the event id cl_gui_alv_grid=>mc_evt_enter already.

I'd try to define a local class to handle the data_changed and data_changed_finished events and put the check_amount and refresh in the method for the data_changed_finished event. Maybe some of this helps you? If you have any questions about any of this, let me know and I can go into more detail.

regards

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM