*&---------------------------------------------------------------------*
*& Report ZGML_TEST
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zgml_test.
TYPES: BEGIN OF tt_alv,
checkbox TYPE xfeld, "复选框
aufnr TYPE aufk-aufnr, "成品订单
aufnr_bcp TYPE aufk-aufnr, "半成品订单
rspos TYPE resb-rspos, "预留 / 相关需求的项目编号
werks TYPE resb-werks, "工厂
matnr TYPE resb-matnr, "半成品订单组件物料
bdmng TYPE resb-bdmng, "数量
meins TYPE resb-meins, "单位
maktx TYPE makt-maktx, "物料描述
END OF tt_alv.
DATA: gt_alv TYPE TABLE OF tt_alv.
DATA: gv_grid_title TYPE lvc_title, "ALV 控制: 标题栏文本
lv_line TYPE int4,
lv_line_string TYPE string.
START-OF-SELECTION.
PERFORM frm_fill_data.
DESCRIBE TABLE gt_alv LINES lv_line.
lv_line_string = lv_line.
CONCATENATE '数据条目数:' lv_line_string INTO gv_grid_title.
END-OF-SELECTION.
PERFORM frm_display_data.
*&---------------------------------------------------------------------*
*& Form frm_get_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_fill_data .
DATA:ls_alv LIKE LINE OF gt_alv.
ls_alv-aufnr = '123456789'.
ls_alv-aufnr_bcp = '14785784593'.
ls_alv-rspos = '3'.
ls_alv-werks = '8000'.
ls_alv-matnr = '67895643'.
ls_alv-bdmng = '23'.
ls_alv-meins = 'PCS'.
ls_alv-maktx = '电脑'.
APPEND ls_alv TO gt_alv.
ls_alv-aufnr = '123456789'.
ls_alv-aufnr_bcp = '3237238922'.
ls_alv-rspos = '5'.
ls_alv-werks = '8000'.
ls_alv-matnr = '23677445'.
ls_alv-bdmng = '15'.
ls_alv-meins = 'PCS'.
ls_alv-maktx = '手机'.
APPEND ls_alv TO gt_alv.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_display_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM frm_display_data .
IF gt_alv IS NOT INITIAL.
DATA: lt_fcat TYPE lvc_t_fcat,
ls_layo TYPE lvc_s_layo.
"设置布局
CLEAR ls_layo.
ls_layo-zebra = 'X'. "斑马线
ls_layo-cwidth_opt = 'X'. "最优宽
ls_layo-box_fname = 'CHECKBOX'. "选择
"填充字段内表
PERFORM frm_fill_fcat TABLES lt_fcat.
"ALV展示
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_callback_program = sy-repid
i_callback_pf_status_set = 'FRM_SET_STATUS'
i_callback_user_command = 'FRM_USER_COMMAND'
i_grid_title = gv_grid_title
is_layout_lvc = ls_layo
it_fieldcat_lvc = lt_fcat
TABLES
t_outtab = gt_alv
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form frm_fill_fcat
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> LT_FCAT
*&---------------------------------------------------------------------*
FORM frm_fill_fcat TABLES pt_fcat TYPE lvc_t_fcat.
DATA ls_fcat TYPE lvc_s_fcat.
DEFINE mc_set_fcat.
CLEAR ls_fcat.
ls_fcat-fieldname = &1.
* IF &1 = 'ICON'.
* ls_fcat-icon = 'X'.
* ENDIF.
IF &1 = 'CHECKBOX'.
ls_fcat-checkbox = 'X'.
ls_fcat-edit = 'X'.
* ls_fcat-hotspot = 'X'.
ENDIF.
IF &1 = 'BDMNG'.
ls_fcat-decimals_o = '0'.
ENDIF.
ls_fcat-coltext = &2.
ls_fcat-outputlen = &3.
ls_fcat-no_zero = &4.
APPEND ls_fcat TO pt_fcat.
END-OF-DEFINITION.
mc_set_fcat:
'CHECKBOX' '选择' '' '',
'WERKS' '工厂' '' '',
'AUFNR' '成品订单' '' 'X',
'AUFNR_BCP' '半成品订单' '' 'X',
'RSPOS' '组件行' '' 'X',
'MATNR' '物料' '' 'X',
'BDMNG' '数量' '' '',
'MEINS' '单位' '' '',
'MAKTX' '物料描述' '' ''.
ENDFORM.
FORM frm_set_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZSTATUS'.
ENDFORM.
FORM frm_user_command USING r_ucomm TYPE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA lr_grid TYPE REF TO cl_gui_alv_grid.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = lr_grid.
CALL METHOD lr_grid->check_changed_data.
CASE r_ucomm.
WHEN 'ALL'.
LOOP AT gt_alv ASSIGNING FIELD-SYMBOL(<ls_alv>).
<ls_alv>-checkbox = 'X'.
ENDLOOP.
WHEN 'SAL'.
LOOP AT gt_alv ASSIGNING <ls_alv>.
<ls_alv>-checkbox = ''.
ENDLOOP.
WHEN 'DEL'.
DELETE gt_alv WHERE checkbox = 'X'.
ENDCASE.
DESCRIBE TABLE gt_alv LINES lv_line.
lv_line_string = lv_line.
CONCATENATE '数据条目数:' lv_line_string INTO gv_grid_title.
CALL METHOD lr_grid->set_gridtitle
EXPORTING
i_gridtitle = gv_grid_title.
CALL METHOD lr_grid->check_changed_data.
CALL METHOD lr_grid->refresh_table_display.
* rs_selfield-refresh = 'X'.
* rs_selfield-row_stable = 'X'.
* rs_selfield-col_stable = 'X'.
ENDFORM. "FRM_USER_COMMAND
ABAP自定义复选框的全选,取消全选
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 实现效果: 【全选/取消按钮】点击全选后,下面的子复选框全部选中。【全选/取消按钮】点击取消全选后,下面的子复选框...
- 问题:为什么var is_check = $("#allselect").attr('checked');取不到值...
- 看一下效果: 思想是在radio选择标签上定义伪元素,然后盖上去;WXML: CSS: JS: 更改checkbo...
- 1.自定义el-radio单选框 自定义前: 自定义后: 附上代码 2. 自定义el-checkbox复选框 自定...