首页 > 其他分享 >DEMO:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title

DEMO:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title

时间:2022-10-14 17:37:22浏览次数:43  
标签:REUSE title fieldcat DEMO show lt grid alv line

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

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


效果

DEMO:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title_复制粘贴

选中,删除

DEMO:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title_数据_02

结构和 status


DEMO:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title_数据_03

DEMO: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


DEMO:REUSE_ALV_GRID_DISPLAY 复选框 刷新 grid_title_复选框_05





标签:REUSE,title,fieldcat,DEMO,show,lt,grid,alv,line
From: https://blog.51cto.com/u_15680210/5757539

相关文章

  • .Net Core Mvc (CRUD)Demo
    目录目录顺手联系了个DEMO控制器Index页面Add页面修改页面最后效果顺手联系了个DEMO控制器usingSystem;usingSystem.Collections.Generic;usingSystem.Dynamic;u......
  • Idea运行支付宝网站支付demo踩坑解决及其测试注意事项
    一、前言在一些商城网上中,必不可少的是支付,支付宝和微信比较常见,最近小编也是在研究这一块,看看支付宝怎么进行支付的,支付宝给我们提供了demo和沙箱测试。减少我们的申请的......
  • 自定义的异常类oppdemo12
    //自定义的异常类publicclassMyExceptionextendsException{//双击shift:搜索//传递数字>10privateintdetail;publicMyException(inta){this.d......
  • 异常oppdemo12
    publicclassTest1{publicstaticvoidmain(String[]args){inta=2;intb=0;//选择该代码(sout)后Ctrl+Alt+T即可选择代码块......
  • (抛出)异常oppdemo12
    importjava.sql.SQLOutput;publicclassTest{publicstaticvoidmain(String[]args){//方法中处理的了异常,newTest().test(1,0);一行代码就够了......
  • 重写多态oppdemo7
    publicclassPerson{publicvoidrun(){System.out.println("father");}}/*多态注意事项:1.多态是方法的多态,属性没有多态2.父类和子类有联系类型转换......
  • 有参无参构造器oppdemo2
    //java文件-->class文件publicclassPerson{//一个类即使什么都不写,它也会存在一个方法//显示的定义构造器Stringname;//实例化初始值//使用new关......
  • 无参构造oppdemo3
    publicclassPet{publicStringname;publicintage;//无参构造publicvoidshout(){System.out.println("叫了一声");}}publicclassA......
  • 类实例化oppdemo2
    //学生类publicclassStudent{//属性:字段Stringname;//nullintage;//0//方法publicvoidstudy(){System.out.println(this.name+"在学习......
  • RESTfulDEMO一:SAP如何提供RESTfulWeb服务
    SAP推荐以OData方式提供RestfulService。Netweaver7.4之后的版本可以直接使用OData服务。7.4之前的版本需要升级GW_CORE、IW_FND和IW_BEP三个核心组件(参见SA......