ABAP 将单元格设置编辑状态 FORM

FORM set_style  USING   fieldname
                        style TYPE string
                CHANGING   it_styles TYPE lvc_t_styl.

  DATA: ls_style TYPE lvc_s_styl.
  CLEAR ls_style.

  ls_style-fieldname = fieldname.
  IF style EQ 'ENABLE'.
    ls_style-style = cl_gui_alv_grid=>mc_style_enabled.
  ELSE.
    ls_style-style = cl_gui_alv_grid=>mc_style_disabled.
  ENDIF.
  READ TABLE it_styles TRANSPORTING NO FIELDS WITH KEY fieldname = fieldname.
  IF sy-subrc EQ 0.
    MODIFY it_styles FROM ls_style INDEX sy-tabix.
  ELSE.
    INSERT ls_style INTO TABLE it_styles.
  ENDIF.

  FREE: ls_style.

ENDFORM.                    " SET_STYLE

 

例如:PERFORM set_style  USING 'ZYY' 'DISABLE' CHANGING <data>-style.

posted @ 2016-08-10 12:12  東東東東  阅读(949)  评论(0编辑  收藏  举报