Koşula Göre Hücrenin Veri Girişine Açılması Yada Kapatılması
Koşul olmadığı durumlarda bir kolonun yukarından aşağıya tamamı fieldcatalog ayarlarından "<ls_fieldcat>-edit = abap_true." ile veri girişine açılabilir yada kapatılabilir. Fakat koşula göre kolondaki bazı hücrelerin girişe açık yada kapalı olması cl_gui_alv_grid=>mc_style_enabled ve cl_gui_alv_grid=>mc_style_disabled ile sağlanabilir.
Rapor ilk görüntülenirken yada raporda bir değişiklik yapılıp handle_data_changed içine düşüldüğünde, yada herhangi bir fonksiyon içinde hücrenin edit edilme özelliği değiştirilmek istenirse aşağıdaki method kullanılabilir.
me->set_non_editable_fields( EXPORTING iv_indfr = lv_tabix
iv_indto = lv_tabix ).
Hücrenin edit özelliği dışında ls_celltab-style2, 3, 4 içinde cl_gui_alv_grid=>mc_style_hotspot gibi başka atamalar da yapılabilir.
*********************
*Class Definition
METHODS:
.
set_non_editable_fields IMPORTING iv_indfr TYPE lvc_index
iv_indto TYPE lvc_index,
fill_celltab IMPORTING iv_fname TYPE lvc_fname
iv_type TYPE char1
EXPORTING et_celltab TYPE lvc_t_styl.
*********************
*********************
END-OF-SELECTION.
go_main->end_of_selection( ).
*********************
*********************
METHOD end_of_selection.
DATA: lv_line TYPE lvc_index.
LOOP AT me->mt_100_itab ASSIGNING FIELD-SYMBOL(<lfs_itab>)
WHERE NOT ( procstat EQ `02` OR procstat EQ `05` ).
lv_line = sy-tabix.
me->set_non_editable_fields( EXPORTING iv_indfr = lv_line
iv_indto = lv_line ).
ENDLOOP.
UNASSIGN <lfs_itab>.
me->create_alv_objects_100( ).
CALL SCREEN 0100.
ENDMETHOD.
*********************
*********************
METHOD set_non_editable_fields.
DATA: lt_celltab TYPE lvc_t_styl,
ls_celltab TYPE lvc_s_styl,
lv_index TYPE lvc_index.
CHECK me->mt_100_itab IS NOT INITIAL.
LOOP AT me->mt_100_itab ASSIGNING FIELD-SYMBOL(<lfs_itab>)
FROM iv_indfr TO iv_indto.
REFRESH lt_celltab.
IF <lfs_itab>-procstat EQ `02` OR <lfs_itab>-procstat EQ `05`.
* me->fill_celltab( EXPORTING iv_fname = `ALL`
* iv_type = `D`
* IMPORTING et_celltab = lt_celltab ).
me->fill_celltab( EXPORTING iv_fname = `FATNO`
iv_type = `E`
IMPORTING et_celltab = lt_celltab ).
ELSE.
me->fill_celltab( EXPORTING iv_fname = `FATNO`
iv_type = `D`
IMPORTING et_celltab = lt_celltab ).
ENDIF.
REFRESH: <lfs_itab>-celltab[].
INSERT LINES OF lt_celltab INTO TABLE <lfs_itab>-celltab.
ENDLOOP.
ENDMETHOD.
*********************
*********************
METHOD fill_celltab.
DATA: ls_celltab TYPE lvc_s_styl,
ls_fcat_0101 TYPE lvc_s_fcat.
"`ALL` adında bir alan olursa sorun olur. Dikkat!
IF iv_fname EQ `ALL` AND iv_type EQ `E`. "Enable all
LOOP AT gt_fcat_0101 INTO ls_fcat_0101.
CLEAR ls_celltab.
ls_celltab-fieldname = ls_fcat_0101-fieldname.
IF ls_fcat_0101-fieldname EQ `FAT_NO`.
ls_celltab-style = cl_gui_alv_grid=>mc_style_hotspot.
ls_celltab-style2 = cl_gui_alv_grid=>mc_style_enabled.
ELSE.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
ENDIF.
INSERT ls_celltab INTO TABLE et_celltab.
ENDLOOP.
ELSEIF iv_fname EQ `ALL` AND iv_type EQ `D`. "Disable all
LOOP AT gt_fcat_0101 INTO ls_fcat_0101.
CLEAR ls_celltab.
ls_celltab-fieldname = ls_fcat_0101-fieldname.
IF ls_fcat_0101-fieldname EQ `FAT_NO`.
ls_celltab-style = cl_gui_alv_grid=>mc_style_hotspot_no.
ls_celltab-style2 = cl_gui_alv_grid=>mc_style_disabled.
ELSE.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
INSERT ls_celltab INTO TABLE et_celltab.
ENDLOOP.
ELSE.
READ TABLE gt_fcat_0101 ASSIGNING FIELD-SYMBOL(<lfs_fcat>)
WITH KEY fieldname = iv_fname
BINARY SEARCH.
IF sy-subrc = 0.
IF iv_type EQ `E`.
CLEAR ls_celltab.
ls_celltab-fieldname = <lfs_fcat>-fieldname.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
IF <lfs_fcat>-fieldname EQ `FAT_NO`.
ls_celltab-style = cl_gui_alv_grid=>mc_style_hotspot.
ls_celltab-style2 = cl_gui_alv_grid=>mc_style_enabled.
ELSE.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
ENDIF.
READ TABLE et_celltab TRANSPORTING NO FIELDS
WITH KEY fieldname = <lfs_fcat>-fieldname.
IF sy-subrc = 0.
MODIFY et_celltab FROM ls_celltab INDEX sy-tabix.
ELSE.
INSERT ls_celltab INTO TABLE et_celltab.
ENDIF.
ELSEIF iv_type EQ `D`.
CLEAR ls_celltab.
ls_celltab-fieldname = <lfs_fcat>-fieldname.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
IF <lfs_fcat>-fieldname EQ `FAT_NO`.
ls_celltab-style = cl_gui_alv_grid=>mc_style_hotspot_no.
ls_celltab-style2 = cl_gui_alv_grid=>mc_style_disabled.
ELSE.
ls_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
ENDIF.
READ TABLE et_celltab TRANSPORTING NO FIELDS
WITH KEY fieldname = <lfs_fcat>-fieldname.
IF sy-subrc = 0.
MODIFY et_celltab FROM ls_celltab INDEX sy-tabix.
ELSE.
INSERT ls_celltab INTO TABLE et_celltab.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDMETHOD.
*********************