首页 > 其他分享 >ALV DMEO 11:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title

ALV DMEO 11:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title

时间:2022-10-14 19:09:15浏览次数:65  
标签:11 REUSE show fieldcat alv lt grid ALV line

以下是纯顾问群~
QQ群 :SAP干货铺,  群号:775662808
所有群管理严格,严格禁止一切外来链接、招聘、广告等垃圾信息!

如果您觉得这篇干货文章有用,请帮忙转载、分享给更多人,谢谢~

直接上干货吧~


最近写了几个 Function ALV 复选框+刷新的报表,

为了方便复制粘贴到其他项目修改,做了个demo。


效果

ALV DMEO 11:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title_复制粘贴

选中,删除

ALV DMEO 11:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title_微信_02

结构和 status


ALV DMEO 11:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title_微信_03

ALV DMEO 11:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title_数据_04


代码


REPORT  zalv_demo

DATA:lt_alv_show LIKE TABLE OF ztest_spfli.
DATA:i_grid_title TYPE lvc_title.
DATA:lv_line TYPE int4.
DATA:ls_line TYPE string.
DATA:lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA:is_layout TYPE slis_layout_alv.
FIELD-SYMBOLS <ls_filed> LIKE LINE OF lt_fieldcat." CHECKBOX


START-OF-SELECTION.

SELECT * FROM spfli INTO CORRESPONDING FIELDS OF TABLE lt_alv_show.

DESCRIBE TABLE lt_alv_show LINES lv_line.

ls_line = lv_line.

CONCATENATE '数据条目数:' ls_line INTO i_grid_title.

CLEAR lt_fieldcat[].
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZTEST_SPFLI'
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.

IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.

LOOP AT lt_fieldcat ASSIGNING <ls_filed> WHERE fieldname = 'CHECKBOX'.
<ls_filed>-checkbox = 'X'.
<ls_filed>-edit = 'X'.
<ls_filed>-seltext_l = '选择'.
<ls_filed>-seltext_m = '选择'.
<ls_filed>-seltext_s = '选择'.
ENDLOOP.


is_layout-colwidth_optimize = 'X' .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_grid_title = i_grid_title
i_callback_program = sy-repid "
is_layout = is_layout
it_fieldcat = lt_fieldcat[]
i_callback_pf_status_set = 'ZFORM_SET_PF_STATUS' "
i_callback_user_command = 'ALV_USER_COMMAND'
TABLES
t_outtab = lt_alv_show
EXCEPTIONS
program_error = 1
OTHERS = 2.


*&---------------------------------------------------------------------*
*& Form zform_set_pf_status
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->RT_EXTAB text
*----------------------------------------------------------------------*
FORM zform_set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'STANDARD' .
ENDFORM. "zform_set_PF_STATUS


*&---------------------------------------------------------------------*
*& Form alv_user_command
*&---------------------------------------------------------------------*


FORM alv_user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.

DATA:lv_err TYPE string.
DATA: l_grid TYPE REF TO cl_gui_alv_grid.
FIELD-SYMBOLS <ls_alv> LIKE LINE OF lt_alv_show.
DATA:ls_alv LIKE LINE OF lt_alv_show.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = l_grid.


CALL METHOD l_grid->check_changed_data.
CALL METHOD l_grid->refresh_table_display.

CASE r_ucomm.

WHEN 'DEL'.
DELETE lt_alv_show WHERE checkbox = 'X' .

WHEN 'ALL'.
LOOP AT lt_alv_show ASSIGNING <ls_alv> .
<ls_alv>-checkbox = 'X'.
ENDLOOP.
WHEN 'SAL'.
LOOP AT lt_alv_show ASSIGNING <ls_alv> .
<ls_alv>-checkbox = ''.
ENDLOOP.

WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'LEAVE'.
LEAVE PROGRAM.

ENDCASE .


DESCRIBE TABLE lt_alv_show LINES lv_line.
ls_line = lv_line.

CONCATENATE '数据条目数:' ls_line INTO i_grid_title.

CALL METHOD l_grid->set_gridtitle
EXPORTING
i_gridtitle = i_grid_title.

CALL METHOD l_grid->check_changed_data.
CALL METHOD l_grid->refresh_table_display.
**
* rs_selfield-refresh = 'X'.
*
* rs_selfield-col_stable = 'X'.
* rs_selfield-row_stable = 'X'.
ENDFORM . "ALV_USER_COMMAND

标签:11,REUSE,show,fieldcat,alv,lt,grid,ALV,line
From: https://blog.51cto.com/u_15680210/5757794

相关文章

  • win11+wls2+ubuntu2004配置cuda+cudnn+pytorch
    0.前置说明win11系统开启子系统wsl2安装Ubuntu2004版本子系统(2204版本未测试,请自测)1.安装wsl2-Ubuntu2004子系统win11以上默认是wsl2了,win10参考列表第一个子系统......
  • Demo:cl_salv_table ALV 弹出框
    效果图:代码REPORTZLM_001.DATA:go_alvTYPEREFTOcl_salv_table,go_funlstTYPEREFTOcl_salv_functions_list.DATA:gt_dataTYPESTANDARDTABLEOFspfli......
  • ALV标题居中加粗
    效果图用的FM的ALV,主要代码如下:关于那个宏,直接用下面的就行TEXT='UserName:'.CALLMETHODDOCUMENT->ADD_TEXTEXPORTINGTEXT=TEXTSAP_EMP......
  • ALV 单元格级别控制编辑
    效果:代码:DATA:BEGINOFGS_DATA.INCLUDESTRUCTURESPFLI.DATA:CELL_STYLETYPELVC_T_STYL,"为内表添加设置编辑状态所需的字段ENDO......
  • ALV 红绿灯 单元格背景色 ion SALV_TEST_TOOLTIPS
    这是一个标准Demo程序,效果:可以直接进系统查看代码SALV_TEST_TOOLTIPS......
  • ALV Header Item 多层显示
    代码参考的*&---------------------------------------------------------------------**&ReportYLM_0003*&*&-------------------------------------------------------......
  • ALV 导出电子表格的文件格式固定的删除办法
    在ALV显示中,选择菜单“列表-导出-电子表格”后,会出现下面这样的选择窗口:如果选中了“始终使用选定的格式”,则以后都会使用当前选定的格式(经常是第一项MHTML,可实际上用户希......
  • 解决Project facet Java version 11 is not supported.问题
    出现该提示说明项目是其他版本jdk编译的,在eclipse里运行时会报版本不支持。解决方法:首先查看本机电脑的jdk版本(cmd→Java-version),然后选中项目Properties,选择Projec......
  • ALV 相关
    目录:1​​ALV双击弹出新ALV,并响应新ALV事件​​2​​DEMO:ALV 行、列、单元格颜色控制​​3​​Demo: DisableDELETEkeyonKeyboard​​4​​ALV输入数据后点回车自......
  • DEMO:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title
    最近写了几个FunctionALV复选框+刷新的报表,为了方便复制粘贴到其他项目修改,做了个demo。效果选中,删除结构和status代码REPORTzalv_demoDATA:lt_alv_showLIKET......