ALV编辑单元格
示例演示:
- SE11表:
- 源代码:
*&---------------------------------------------------------------------*
*& Report ZXHN_EDIT_ALV
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZXHN_EDIT_ALV.
TYPE-POOLS: slis.
TABLES: ZXHN_EDIT_ALV .
TYPES: BEGIN OF ty_out,
zid TYPE ZXHN_EDIT_ALV-zid,
zname TYPE ZXHN_EDIT_ALV-zname,
zage TYPE ZXHN_EDIT_ALV-zage,
selec TYPE char1,
celltab TYPE lvc_t_styl,
END OF ty_out .
DATA: gt_out TYPE TABLE OF ty_out,
gs_out TYPE ty_out.
DATA:t_fieldcat TYPE lvc_t_fcat,
w_fieldcat TYPE LINE OF lvc_t_fcat,
t_layout TYPE lvc_s_layo.
DATA:rt_extab TYPE slis_t_extab.
DATA g_grid TYPE REF TO cl_gui_alv_grid.
DATA stbl TYPE lvc_s_stbl.
DATA ls_celltab TYPE LVC_S_STYL.
DATA lt_celltab TYPE lvc_t_styl.
SELECTION-SCREEN:BEGIN OF BLOCK a1 WITH FRAME TITLE text-001.
SELECT-OPTIONS:s_zid FOR ZXHN_EDIT_ALV-zid,
s_zname FOR ZXHN_EDIT_ALV-zname,
s_zage FOR ZXHN_EDIT_ALV-zage.
SELECTION-SCREEN:END OF BLOCK a1.
START-OF-SELECTION.
*-----------------------获取数据
PERFORM frm_get_data.
PERFORM frm_handle_data.
PERFORM frm_alv_show.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Form FRM_GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_GET_DATA .
SELECT * INTO CORRESPONDING FIELDS OF TABLE gt_out
FROM ZXHN_EDIT_ALV
WHERE zid IN s_zid
AND zname IN s_zname
AND zage IN s_zage .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_ALV_SHOW
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_ALV_SHOW .
PERFORM frm_init_layout.
PERFORM frm_set_fieldset.
PERFORM frm_output_alv.
PERFORM f_status USING rt_extab.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_INIT_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_INIT_LAYOUT .
t_layout-cwidth_opt = 'X'.
t_layout-zebra = 'X'.
t_layout-box_fname = 'SELEC'.
t_layout-stylefname = 'CELLTAB' .
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_SET_FIELDSET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FRM_SET_FIELDSET .
PERFORM frm_init_fieldcat USING 'ZID' '学号' '' 10.
PERFORM frm_init_fieldcat USING 'ZNAME' '名字' '' 30.
PERFORM frm_init_fieldcat USING 'ZAGE' '年龄' 'X' 10.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FRM_INIT_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0153 text
* -->P_0154 text
* -->P_10 text
*----------------------------------------------------------------------*
FORM FRM_INIT_FIELDCAT USING fieldcatname LIKE w_fieldcat-fieldname
seltext LIKE w_fieldcat-scrtext_l
edit LIKE w_fieldcat-edit
len LIKE w_fieldcat-outputlen.
CLEAR w_fieldcat.
w_fieldcat-fieldname = fieldcatname .
w_fieldcat-scrtext_l = seltext.
w_fieldcat-edit =