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: 

Making the cell as editable after an event

0 Kudos

Hi all,

I try to make a cell editable according on the value selected from dropdown but she stay disabled.

I use event DATA_CHANGED like below :


METHOD handle_data_changed.

*-----------< Déclaration >----------------*
     DATA:
* Structures
           ls_good_cost TYPE lvc_s_modi
         , ls_cellstyle TYPE lvc_s_styl
* Variables
         .

* Pointeurs
     FIELD-SYMBOLS:
           <ls_data_changed> TYPE lvc_s_modi
         .

*-----------< Début traitement >-----------*

*--- Lecture de la valeur modifiée
     LOOP AT er_data_changed->mt_good_cells ASSIGNING <ls_data_changed>.

       IF <ls_data_changed>-fieldname = 'PEC'.

         CASE <ls_data_changed>-value.
           WHEN 'N'                "Non pertinant
                OR 'E'.               "Exception / Hors périmètre

*--- Ajout du paramètre editable de la cellule
             READ TABLE gt_amo_error INDEX <ls_data_changed>-row_id
                                     ASSIGNING <gs_amo_error>.
             IF sy-subrc = 0.
               ls_cellstyle-fieldname = 'COMMENTAIRE'.
               ls_cellstyle-style     = cl_gui_alv_grid=>mc_style_enabled.
               APPEND ls_cellstyle TO <gs_amo_error>-cellstyles.
               FREE ls_cellstyle.
             ENDIF.

           WHEN OTHERS.
             "Ne rien faire

         ENDCASE.

       ENDIF.

     ENDLOOP.

*-----------< Fin   traitement >-----------*

   ENDMETHOD.


Thanks for your help.

1 ACCEPTED SOLUTION

SimoneMilesi
Active Contributor
0 Kudos

Did you call the method REFRESH for the grid at the end of event DATA_CHANGE_FINISHED?

4 REPLIES 4

SimoneMilesi
Active Contributor
0 Kudos

Did you call the method REFRESH for the grid at the end of event DATA_CHANGE_FINISHED?

0 Kudos

No, I didn't.

I just call the event DATA_CHANGED, but I tried that :

READ TABLE gt_amo_error INDEX <ls_data_changed>-row_id
                                          ASSIGNING <gs_amo_error>.
IF sy-subrc = 0.
   READ TABLE <gs_amo_error>-cellstyles INDEX 1
                                        ASSIGNING <ls_cellstyles>.
   IF sy-subrc = 0.
     <ls_cellstyles>-style = cl_gui_alv_grid=>mc_style_enabled.
     UNASSIGN <ls_cellstyles>.
   ENDIF.
   UNASSIGN <gs_amo_error>.
ENDIF.

And I wrote that in PBO :

READ TABLE gt_fcat WITH KEY fieldname = 'COMMENTAIRE'
                    ASSIGNING <gs_fcat>.
IF sy-subrc = 0.
  <gs_fcat>-edit = abap_true.
  UNASSIGN <gs_fcat>.
ENDIF.

DATA ls_cellstyle TYPE lvc_s_styl.
LOOP AT gt_amo_error ASSIGNING <gs_amo_error>.
  ls_cellstyle-fieldname = 'COMMENTAIRE'.
  ls_cellstyle-style     = cl_gui_alv_grid=>mc_style_disabled.
  APPEND ls_cellstyle TO <gs_amo_error>-cellstyles.
  FREE ls_cellstyle.
ENDLOOP.

But, i don't have that I want because only the last modified line is taken into account : .

0 Kudos

You have to call er_data_changed->MODIFY_STYLE during the event DATA_CHANGED. No need to call refresh_table_display.

Sandra_Rossi
Active Contributor
0 Kudos

You must make your ALV grid editable: either field EDIT = 'X' of the layout parameter (of SET_TABLE_FOR_FIRST_DISPLAY), or SET_READY_FOR_INPUT( 1 ). You may only make one column editable using field EDIT = 'X' of field catalog

Message was edited by: Sandra Rossi My answer was not relevant