alv+checkbox+select all
标准程序 bcalv_edit_05 提供了alv使用checkbox和各种操作。 下面程序将bcalv_edit_05 简化了。。要运行程序,需要自己创建 screen和GUI-status,GUI-title...
REPORT ZWTEST.
data: ok_code like sy-ucomm,
save_ok like sy-ucomm,
g_container type scrfname value 'PACKINGLIST_GRID_0100', "这个是屏幕控件名
g_grid type ref to cl_gui_alv_grid,
g_custom_container type ref to cl_gui_custom_container,
gt_fieldcat type lvc_t_fcat,
gs_layout type lvc_s_layo,
g_max type i value 100.
*
*§A1.Extend your output table by a checkbox field.
* If you do not want to lock sole checkboxes against input
* you do not need field 'celltab'.
types: begin of gs_outtab.
types: checkbox type c. "field for checkbox
* §B1.Extend your output table by a field to dis- or enable
* cells for input.
types: celltab type lvc_t_styl. "field to switch editability
include structure sflight.
types: end of gs_outtab.
data: gt_outtab type gs_outtab occurs 0 with header line.
*
********************************************************************
*---------------------------------------------------------------------*
* MAIN *
*---------------------------------------------------------------------*
end-of-selection.
call screen 100.
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
module pbo output.
set pf-status 'MAIN100'.
set titlebar 'MAIN100'.
if g_custom_container is initial.
perform create_and_init_alv.
endif.
endmodule.
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
module pai input.
save_ok = ok_code.
clear ok_code.
case save_ok.
when 'EXIT'.
perform exit_program.
when 'SELECT'.
perform select_all_entries changing gt_outtab[].
when 'DESELECT'.
perform deselect_all_entries changing gt_outtab[].
when 'RESET'.
perform reset_selected_entries changing gt_outtab[].
endcase.
endmodule.
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
form exit_program.
leave program.
endform.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_FIELDCAT text
*----------------------------------------------------------------------*
form build_fieldcat changing pt_fieldcat type lvc_t_fcat.
data ls_fcat type lvc_s_fcat.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'SFLIGHT'
changing
ct_fieldcat = pt_fieldcat.
*§A2.Add an entry for the checkbox in the fieldcatalog
clear ls_fcat.
ls_fcat-fieldname = 'CHECKBOX'.
* Essential: declare field as checkbox and
* mark it as editable field:
ls_fcat-checkbox = 'X'.
ls_fcat-edit = 'X'.
* do not forget to provide texts for this extra field
ls_fcat-coltext = text-f01.
ls_fcat-tooltip = text-f02.
ls_fcat-seltext = text-f03.
* optional: set column width
ls_fcat-outputlen = 10.
*
append ls_fcat to pt_fieldcat.
endform.
*&---------------------------------------------------------------------*
*& Form CREATE_AND_INIT_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_OUTTAB text
* <--P_GT_FIELDCAT text
* <--P_GS_LAYOUT text
*----------------------------------------------------------------------*
form create_and_init_alv.
data: lt_exclude type ui_functions.
create object g_custom_container
exporting container_name = g_container.
create object g_grid
exporting i_parent = g_custom_container.
perform build_fieldcat changing gt_fieldcat.
* Exclude all edit functions in this example since we do not need them:
perform exclude_tb_functions changing lt_exclude.
perform build_data.
*§ B3.Use the layout structure to aquaint additional field to ALV.
gs_layout-stylefname = 'CELLTAB'.
call method g_grid->set_table_for_first_display
exporting is_layout = gs_layout
it_toolbar_excluding = lt_exclude
changing it_fieldcatalog = gt_fieldcat
it_outtab = gt_outtab[].
* Set editable cells to ready for input initially
call method g_grid->set_ready_for_input
exporting
i_ready_for_input = 1.
endform. "CREATE_AND_INIT_ALV
*&---------------------------------------------------------------------*
*& Form EXCLUDE_TB_FUNCTIONS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LT_EXCLUDE text
*----------------------------------------------------------------------*
form exclude_tb_functions changing pt_exclude type ui_functions.
data ls_exclude type ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
append ls_exclude to pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_loc_undo.
append ls_exclude to pt_exclude.
endform. " EXCLUDE_TB_FUNCTIONS
*&---------------------------------------------------------------------*
*& Form build_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form build_data.
data: lt_sflight type table of sflight,
ls_sflight type sflight,
ls_celltab type lvc_s_styl,
lt_celltab type lvc_t_styl,
l_index type i.
select * from sflight into table lt_sflight up to g_max rows.
if sy-subrc ne 0.
* generate own entries if db-table is empty so that this example
* still works
perform generate_entries changing lt_sflight.
endif.
*§A3.Optionally, check checkboxes initially after selecting data.
* (Omitted in this example)
loop at lt_sflight into ls_sflight.
move-corresponding ls_sflight to gt_outtab.
* if gt_outtab-connid eq '400'.
* gt_outtab-checkbox = 'X'.
* endif.
append gt_outtab.
endloop.
* §B2.After selecting data,
* assign a style for each row of your checkbox column.
*
* Initially, set all checkbox cells editable.
ls_celltab-fieldname = 'CHECKBOX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
loop at gt_outtab.
l_index = sy-tabix.
refresh lt_celltab.
ls_celltab-fieldname = 'CHECKBOX'.
ls_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
insert ls_celltab into table lt_celltab.
insert lines of lt_celltab into table gt_outtab-celltab.
modify gt_outtab index l_index.
endloop.
endform. " build_data
*&---------------------------------------------------------------------*
*& Form generate_entries
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_LT_SLFIGHT text
*----------------------------------------------------------------------*
form generate_entries changing pt_slfight type standard table.
*
* This form is only needed for the case that there is no
* data in database table SFLIGHT.
*
data: ls_sflight type sflight,
l_month(2) type c,
l_day(2) type c,
l_date(8) type c.
ls_sflight-carrid = 'LH'.
ls_sflight-connid = '0400'.
ls_sflight-currency = 'DEM'.
ls_sflight-planetype = '747-400'.
ls_sflight-seatsmax = 660.
do 110 times.
ls_sflight-price = sy-index * 100.
ls_sflight-seatsocc = 660 - sy-index * 6.
ls_sflight-paymentsum = ls_sflight-seatsocc * ls_sflight-price.
l_month = sy-index / 10 + 1.
do 2 times.
l_day = l_month + sy-index * 2.
l_date+0(4) = '2000'.
l_date+4(2) = l_month+0(2).
l_date+6(2) = l_day+0(2).
ls_sflight-fldate = l_date.
append ls_sflight to pt_slfight.
enddo.
enddo.
endform. " generate_entries
*&---------------------------------------------------------------------*
*& Form select_all_entries
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_OUTTAB text
*----------------------------------------------------------------------*
form select_all_entries changing pt_outtab type standard table.
data: ls_outtab type gs_outtab.
data: l_valid type c.
*§A4ad. Before you (a)set, reset or (d)evaluate checkboxes,
* you must check the input cells.
*
* If all entries are ok, ALV transferes new values to the output
* table which you then can modify.
call method g_grid->check_changed_data
importing
e_valid = l_valid.
if l_valid eq 'X'.
loop at pt_outtab into ls_outtab.
if not ls_outtab-checkbox eq '-'.
ls_outtab-checkbox = 'X'.
endif.
modify pt_outtab from ls_outtab.
endloop.
call method g_grid->refresh_table_display.
endif.
endform. " select_all_entries
*&---------------------------------------------------------------------*
*& Form deselect_all_entries
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_OUTTAB[] text
*----------------------------------------------------------------------*
form deselect_all_entries changing pt_outtab type standard table.
data: ls_outtab type gs_outtab.
data: l_valid type c,
l_locked type c.
call method g_grid->check_changed_data
importing
e_valid = l_valid.
if l_valid eq 'X'.
loop at pt_outtab into ls_outtab.
perform check_lock using ls_outtab
changing l_locked.
if l_locked is initial
and not ls_outtab-checkbox eq '-'.
ls_outtab-checkbox = ' '.
endif.
modify pt_outtab from ls_outtab.
endloop.
call method g_grid->refresh_table_display.
endif.
endform. " deselect_all_entries
*&---------------------------------------------------------------------*
*& Form reset_selected_entries
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_OUTTAB[] text
*----------------------------------------------------------------------*
form reset_selected_entries changing pt_outtab type standard table.
data: ls_outtab type gs_outtab.
data: l_valid type c.
endform. " reset_selected_entries
*&---------------------------------------------------------------------*
*& Form check_lock
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LS_OUTTAB text
* <--P_L_LOCKED text
*----------------------------------------------------------------------*
form check_lock using ps_outtab type gs_outtab
changing p_locked.
data ls_celltab type lvc_s_styl.
loop at ps_outtab-celltab into ls_celltab.
if ls_celltab-fieldname = 'CHECKBOX'.
if ls_celltab-style eq cl_gui_alv_grid=>mc_style_disabled.
p_locked = 'X'.
else.
p_locked = space.
endif.
endif.
endloop.
endform. " check_lock
alv+checkbox+select all相关推荐
- ALV Checkbox 单行灰显
用 Function Module REUSE_ALV_GRID_DISPLAY 处理 ALV Checkbox 时,只能整列灰显Checkbox. 而用 Function Module REUSE_ ...
- JQUERY对RADIO,CHECKBOX,SELECT的操作常用方法大全
JQUERY对RADIO,CHECKBOX,SELECT的操作 ******************************************************************** ...
- jquery取得text,areatext,radio,checkbox,select的值
query取得text,areatext,radio,checkbox,select的值,以及其他一些操作; 1.假如我们有如下页面 <input type="text" n ...
- jquery操作radio/checkbox/select 及其相关
获取一组radio被选中项的值 var item = $('input[@name=items][@checked]').val(); 获取select被选中项的文本 var item = $(&qu ...
- JQUERY获取text,areatext,radio,checkbox,select值
jquery radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中,及其相关 获取一组radio被选中项的值 var item = $('in ...
- jQuery的radio,checkbox,select操作
获取一组radio被选中项的值 var item = $('input[@name=items][@checked]').val(); 获取select被选中项的文本 var item = $(&qu ...
- JQuery选择器及radio,checkbox,select取值和反选
jQuery 的选择器可谓之强大无比,这里简单地总结一下常用的元素查找方法 $("#myELement") 选择id值等于myElement的元素,id值不能重复在文档中只能 ...
- angularjs-控制form及radio,checkbox,select
#ng-value可以填写表达式 <!DOCTYPE html> <html><head><meta charset="UTF-8"> ...
- OO ALV checkbox更新的问题
OO ALV在CHECKBOX的处理与FUNCTION ALV有稍微的不同,在调用set_table_for_first_display后需要加上以下语句才能实现点击后自动更新内表. CALL MET ...
最新文章
- html自定义鼠标右键,js自定义鼠标右键的实现原理及源码
- 电源功耗压力测试软件,开关电源负载测试经验分享——这篇三分钟小文章着实令人“心动”...
- 财付通php接口,dedecms 财付通接口,dedecms财付通_PHP教程
- sql语句,怎么取查询结果的位置
- MVC 3 基本操作增加修改
- Python大数据系列-01-关系数据库基本运算
- 计算机无论采用何种方式接入网络,自考计算机网络实用技术考核知识点之Internet的结构及其接入方式...
- NUC1397 Oil Deposits【DFS】
- 去掉内容中的所有全部html标签。
- WebView·开车指南
- X5之position_estimator_inav_main.c
- 【JS】match() 方法
- 企业网站建设常用CMS建站系统推荐
- 偶数提取(不用二次倒位,直接一步到位)
- 2022年西藏最新八大员之(安全员)模拟试题题库及答案
- 思科服务器如何重装系统,【干货】思科 ios 软件的安装升级方法
- mysql统计用户留存_SQL 统计用户留存
- Xsolla与Ubisoft游戏Rainbow Six Siege 和刺客信条:辛迪加展开战略合作
- 扫地机器人腿是咕噜_智能家居 篇一:洒哇地咔钟点狗智能擦地机初步评测:试水之作 略有失望...
- 微软国行解锁服务器,微软Xbox One国行版解锁教程:勇士终翻身