00 alv抬头等
*&---------------------------------------------------------------------*
*& Report ZHJ_TEST06
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------* REPORT zhj_test06.
*变量定义==============================================================
DATA:BEGIN OF it_itab OCCURS .
DATA : light() TYPE c.
INCLUDE STRUCTURE makt."sflight.
DATA: text() TYPE c.
DATA:END OF it_itab. "定义一个容器类
DATA: wcl_container TYPE REF TO cl_gui_custom_container, "定义alv--grid对象
wcl_alv TYPE REF TO cl_gui_alv_grid ,
gt_fieldcat TYPE lvc_t_fcat, "这个表存放标题栏不显示的图标功能码
ex_fcode TYPE ui_functions,
"layout
gs_layout TYPE lvc_s_layo. DATA : container_head TYPE REF TO cl_gui_custom_container ,
cl_viewer TYPE REF TO cl_gui_html_viewer ,
cl_doc TYPE REF TO cl_dd_document .
DATA : l_abck TYPE sdydo_key VALUE space .
DATA : msg TYPE sdydo_text_element . *----------------------------------------------------------------------*
* class lcl_event_receiver definition
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION. PUBLIC SECTION.
METHODS:
*--在alv的工具条上增加新的按钮
handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object
e_interactive,
*--实现用户命令
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm, *--热点点击控制
handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING e_row_id e_column_id es_row_no, *--用户双击事件
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column es_row_no, *--覆盖标准的功能.
handle_before_user_command
FOR EVENT before_user_command OF cl_gui_alv_grid
IMPORTING e_ucomm, *--覆盖标准的功能.
handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING er_data_changed
e_onf4 e_onf4_before
e_onf4_after
e_ucomm,
********页眉
handle_top_page
FOR EVENT top_of_page OF cl_gui_alv_grid
IMPORTING e_dyndoc_id
table_index .
* IMPORTing .
ENDCLASS. "lcl_event_receiver DEFINITION START-OF-SELECTION.
PERFORM get_data."向内表写数据
PERFORM set_fieldcat."设置FIELDCAT
PERFORM set_layout."设置layout
PERFORM set_ex_fcode."设置隐藏工具栏按钮
CALL SCREEN ."需要在屏幕里画一个container *&---------------------------------------------------------------------*
*& form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data . REFRESH it_itab.CLEAR it_itab.
SELECT *
INTO CORRESPONDING FIELDS OF TABLE it_itab
UP TO ROWS
FROM makt.
IF sy-subrc NE .
* MESSAGE e000 WITH '没有数据选择!'.
ENDIF. ENDFORM. " GET_DATA *&---------------------------------------------------------------------*
*& form set_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_fieldcat . * 这个函数只能读取标准结构体的fieldcat
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
* i_buffer_active =
i_structure_name = 'MAKT'
i_client_never_display = 'X'
* i_bypassing_buffer =
* i_internal_tabname =
CHANGING
ct_fieldcat = gt_fieldcat
EXCEPTIONS
inconsistent_interface =
program_error =
OTHERS = .
IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. DATA gs_fieldcat LIKE LINE OF gt_fieldcat.
gs_fieldcat-fieldname = 'LIGHT'.
gs_fieldcat-scrtext_l = '标志'.
* gs_fieldcat-CHECKBOX = 'X'.
INSERT gs_fieldcat INTO gt_fieldcat INDEX . CLEAR gs_fieldcat.
gs_fieldcat-col_pos = .
gs_fieldcat-fieldname = 'TEXT'.
gs_fieldcat-scrtext_l = '文本'.
gs_fieldcat-edit = 'X'.
APPEND gs_fieldcat TO gt_fieldcat. ENDFORM. " SET_FIELDCAT
*&---------------------------------------------------------------------*
*& form output_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM output_display .
CALL METHOD wcl_alv->set_table_for_first_display
EXPORTING
i_save = 'A'
is_layout = gs_layout
it_toolbar_excluding = ex_fcode
CHANGING
it_outtab = it_itab[]
it_fieldcatalog = gt_fieldcat
EXCEPTIONS
invalid_parameter_combination =
program_error =
too_many_lines =
OTHERS = . IF sy-subrc <> .
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. CREATE OBJECT cl_doc . CALL METHOD wcl_alv->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = cl_doc.
ENDFORM. " OUTPUT_DISPLAY
*&---------------------------------------------------------------------*
*& module status_0100 output
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'GUI_STATUS'.
* set titlebar 'xxx'.
IF wcl_alv IS INITIAL. CREATE OBJECT: wcl_container
EXPORTING
container_name = 'ALV_CON'. CREATE OBJECT container_head
EXPORTING
container_name = 'HON_CONT'. CREATE OBJECT wcl_alv
EXPORTING
i_parent = wcl_container. * create and set event
DATA event_receiver TYPE REF TO lcl_event_receiver.
CREATE OBJECT event_receiver.
SET HANDLER event_receiver->handle_toolbar FOR wcl_alv.
SET HANDLER event_receiver->handle_top_page FOR wcl_alv .
SET HANDLER event_receiver->handle_user_command FOR wcl_alv.
SET HANDLER event_receiver->handle_hotspot_click FOR wcl_alv.
SET HANDLER event_receiver->handle_double_click FOR wcl_alv.
SET HANDLER event_receiver->handle_before_user_command FOR wcl_alv.
SET HANDLER event_receiver->handle_data_changed FOR wcl_alv. PERFORM output_display. * set interaction
CALL METHOD wcl_alv->set_toolbar_interactive.
* 注册更新时间
CALL METHOD wcl_alv->register_edit_event
EXPORTING
i_event_id = wcl_alv->mc_evt_enter. ENDIF. ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& module user_command_0100 input
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT. CASE sy-ucomm.
WHEN '&F03' OR '&F12'.
LEAVE TO SCREEN .
WHEN '&F15'.
LEAVE PROGRAM.
WHEN 'SAVE'.
DATA lt_selected_rows TYPE lvc_t_roid.
CALL METHOD wcl_alv->get_selected_rows
IMPORTING
et_row_no = lt_selected_rows.
* MESSAGE i003 WITH 'USER_COMMAND_0100 event'.
WHEN OTHERS.
ENDCASE. ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& form set_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_layout . gs_layout-zebra = 'X'."条纹格式输出
* gs_layout-edit = 'X'."可编辑状态
gs_layout-smalltitle = 'X'."小标题
* gs_layout-no_hgridln ='X'."隐藏水平网格线
* gs_layout-no_vgridln = 'X'."隐藏垂直网格线
* gs_layout-no_headers = 'X'."隐藏列抬头
* gs_layout-no_merging = 'X'."禁用单元格合并
gs_layout-cwidth_opt = 'X'."优化列宽度
* gs_layout-no_f4 = 'X'."没有F4按键功能
* gs_layout-no_rowmark = 'X'."禁用行选择
* gs_layout-no_toolbar = 'X'."隐藏工具栏
gs_layout-grid_title = 'ALV实例'."标题栏
* gs_layout-sgl_clk_hd = 'X'."单击列标题按升序排列
* gs_layout-no_totline = 'X'."不要输出总计行
gs_layout-keyhot = 'X'."关键列作为热
* gs_layout-info_fname = 'TEXT'."带有简单行彩色代码的字段名称
* gs_layout-ctab_fname = 'TEXT'."带有复杂单元格颜色编码的字段名称 gs_layout-sel_mode = 'C'.
* gs_layout-box_fname = 'CHX'. DATA:l_fielfcat TYPE LINE OF lvc_t_fcat.
LOOP AT gt_fieldcat INTO l_fielfcat.
CASE l_fielfcat-fieldname.
WHEN 'MATNR'.
* fcat_100-ref_table = 'T001W'.
* fcat_100-ref_field = 'WERKS'.
* fcat_100-outputlen = '10'.
l_fielfcat-edit = 'X'.
WHEN OTHERS.
* WHEN 'HSDAT' OR 'ERSDA' OR 'VFDAT'.
* fcat_100-outputlen = '10'.
* FCAT_100-NO_ZERO = 'X'.
ENDCASE.
MODIFY gt_fieldcat FROM l_fielfcat.
CLEAR l_fielfcat.
ENDLOOP. ENDFORM. " SET_LAYOUT
*&---------------------------------------------------------------------*
*& form set_ex_fcode
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_ex_fcode .
REFRESH ex_fcode.CLEAR ex_fcode.
DATA:ls_fcode TYPE ui_func. ls_fcode = cl_gui_alv_grid=>mc_fc_info.
APPEND ls_fcode TO ex_fcode.
ls_fcode = cl_gui_alv_grid=>mc_fc_loc_append_row.
APPEND ls_fcode TO ex_fcode.
ls_fcode = cl_gui_alv_grid=>mc_fc_loc_insert_row.
APPEND ls_fcode TO ex_fcode.
ls_fcode = cl_gui_alv_grid=>mc_fc_loc_delete_row.
APPEND ls_fcode TO ex_fcode.
ls_fcode = cl_gui_alv_grid=>mc_fc_loc_copy_row.
APPEND ls_fcode TO ex_fcode.
ls_fcode = cl_gui_alv_grid=>mc_fc_loc_paste_new_row.
APPEND ls_fcode TO ex_fcode. ENDFORM. " SET_EX_FCODE
*&---------------------------------------------------------------------*
*& class (implementation) lcl_event_receiver
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION. *-- handle toolbar
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object e_interactive.
ENDMETHOD. "handle_toolbar *-- handdle user_command
METHOD handle_user_command.
PERFORM handle_user_commmand CHANGING e_ucomm.
ENDMETHOD. "Handle user command *-- handle_hotspot_click
METHOD handle_hotspot_click.
PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no.
ENDMETHOD. "HANDLE_HOTSPOT_CLICK *--handle_double_click
METHOD handle_double_click.
PERFORM handle_double_click USING e_row e_column es_row_no.
ENDMETHOD. "HANDLE_DOUBLE_CLICK *--before_user_command
METHOD handle_before_user_command.
PERFORM handle_before_user_command USING e_ucomm.
ENDMETHOD. "BEFORE_USER_COMMAND *--before_user_command
METHOD handle_data_changed.
PERFORM handle_data_changed USING er_data_changed.
ENDMETHOD. "BEFORE_USER_COMMAND *--before_user_command
METHOD handle_top_page.
* CREATE OBJECT CL_DOC .
CALL METHOD cl_doc->initialize_document . CALL METHOD cl_doc->add_text
EXPORTING
text = 'qwertyuioplkjhgfdsa'
sap_style = 'HEADING'. IF msg IS NOT INITIAL .
CALL METHOD cl_doc->new_line .
CALL METHOD cl_doc->add_text
EXPORTING
text = msg
sap_emphasis = ''.
CLEAR msg .
ENDIF.
IF cl_viewer IS INITIAL .
CREATE OBJECT cl_viewer
EXPORTING
parent = container_head.
ENDIF. CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
EXPORTING
document = cl_doc
bottom = l_abck
* IMPORTING
* LENGTH =
. CALL METHOD cl_doc->merge_document .
CALL METHOD cl_doc->set_document_background
EXPORTING
picture_id = space. cl_doc->html_control = cl_viewer . CALL METHOD cl_doc->display_document
EXPORTING
reuse_control = 'X'
parent = container_head. *ENDFORM. " FRM_TOP_OF_PAGE ENDMETHOD. "BEFORE_USER_COMMAND ENDCLASS. "LCL_EVENT_RECEIVER
*&---------------------------------------------------------------------*
*& form handle_toolbar
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_e_object text
* -->p_e_interactive text
*----------------------------------------------------------------------*
FORM handle_toolbar USING p_e_object
TYPE REF TO cl_alv_event_toolbar_set
p_e_interactive. DATA: utoolbar TYPE stb_button.
CLEAR utoolbar.
utoolbar-function = 'TEST'.
utoolbar-butn_type = .
utoolbar-icon = icon_color.
utoolbar-quickinfo = 'TEST BUTTON'.
APPEND utoolbar TO p_e_object->mt_toolbar.
CLEAR utoolbar. ENDFORM. " HANDLE_TOOLBAR
*&---------------------------------------------------------------------*
*& form handle_user_commmand
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM handle_user_commmand CHANGING e_ucomm.
CASE e_ucomm.
WHEN 'SHOW'.
MESSAGE 'handle user command event' TYPE 'S'.
WHEN 'TEST'.
MESSAGE '你点击了color按钮' TYPE 'I'.
WHEN 'BACK'.
LEAVE TO SCREEN .
WHEN OTHERS.
MESSAGE 'OTHERS' TYPE 'I'.
ENDCASE.
ENDFORM. " HANDLE_USER_COMMMAND
*&---------------------------------------------------------------------*
*& form handle_hotspot_click
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_e_row_id text
* -->p_e_column_id text
* -->p_es_row_no text
*----------------------------------------------------------------------*
FORM handle_hotspot_click USING p_e_row_id
p_e_column_id
p_es_row_no. DATA:l_s TYPE string.
CONCATENATE '你点击了' p_e_row_id p_e_column_id INTO l_s.
MESSAGE l_s TYPE 'I'. "p_e_row_id p_e_column_id . ENDFORM. " HANDLE_HOTSPOT_CLICK
*&---------------------------------------------------------------------*
*& form handle_double_click
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_e_row_id text
* -->p_e_column_id text
* -->p_es_row_no text
*----------------------------------------------------------------------*
FORM handle_double_click USING p_e_row_id
p_e_column_id
p_es_row_no. MESSAGE '双击事件' TYPE 'I'. ENDFORM. " HANDLE_DOUBLE_CLICK
*&---------------------------------------------------------------------*
*& form handle_before_user_command
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->p_e_ucomm text
*----------------------------------------------------------------------*
FORM handle_before_user_command USING p_e_ucomm.
DATA:l_s TYPE string.
CONCATENATE '按钮的功能码为' p_e_ucomm INTO l_s.
MESSAGE l_s TYPE 'I'. ENDFORM. " HANDLE_BEFORE_USER_COMMAND *&---------------------------------------------------------------------*
*& Form HANDLE_DATA_CHANGED_FINISHED
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_E_UCOMM text
*----------------------------------------------------------------------*
FORM handle_data_changed USING p_er_data_changed
TYPE REF TO cl_alv_changed_data_protocol. * 如果更新的reason字段长度小于10为则提示用户填入字符数不能低于10
DATA: mod_data TYPE lvc_t_modi,
wa_mod_data TYPE lvc_s_modi. mod_data = p_er_data_changed->mt_mod_cells.
LOOP AT mod_data INTO wa_mod_data WHERE fieldname = 'TEXT'.
IF strlen( wa_mod_data-value ) < .
CALL METHOD p_er_data_changed->add_protocol_entry
EXPORTING
i_msgid = ''
i_msgty = 'E'
i_msgno = ''
i_msgv1 = '长度必须大于2 '
i_fieldname = wa_mod_data-fieldname. * 如果长度小于2,则将字段内容更新为长都无法确定
CLEAR wa_mod_data-value.
CALL METHOD p_er_data_changed->modify_cell
EXPORTING
i_row_id = wa_mod_data-row_id
i_fieldname = wa_mod_data-fieldname
i_value = wa_mod_data-value.
ENDIF.
ENDLOOP. ENDFORM. " HANDLE_DATA_CHANGED_FINISHED
00 alv抬头等的更多相关文章
- 一位IT行业高收入者的理财规划方案
一位IT行业高收入者的理财规划方案 http://zhuanlan.zhihu.com/invest/19670220 Alex · 12 天前 回望2013,这一年是极其不寻常的.理财浪潮席卷大江南 ...
- ABAP ALV单个单元格状态编辑
*&---------------------------------------------------------------------* *& Report ZPPR0024 ...
- SAP ALV显示并打印(非OO方式)
*&---------------------------------------------------------------------* *& Report Z_SD_CPF ...
- ALV 行列 颜色
1)颜色含义 1:海蓝:2:浅清:3:黄色:4:浅蓝:5:青色:6:红色:7:橙色.(1)首位为主颜色:(2)次位为辅助颜色:(3)末位为0时,表示首位数字表为表格的底色:末位为1时,则表示以1为底色 ...
- 马云18年前制止偷井盖视频走红 2013-05-10 11:00:37 来源: 新快报(广州) 有0人参与 分享到 网易微博 新浪微博 腾讯空间 人人网 有道云笔记 在一次访谈中,即将卸任阿里巴巴CEO的马云自曝了他第一次上电视是在1995年。“我刚开始创
马云18年前制止偷井盖视频走红 2013-05-10 11:00:37 来源: 新快报(广州) 有0人参与 分享到 网易微博 新浪微博 腾讯空间 人人网 有道云笔记 在一次访谈中,即将卸任阿里巴巴 ...
- ALV行 列颜色设置
ALV的颜色设置分为3种:行.列.单元格. 1.列颜色的设置 在 slis_t_fieldcat_alv-emphasize 中,写入需要的颜色代码. Eg: DATA: fc TYP ...
- C#得到某月最后一天晚上23:59:59和某月第一天00:00:00
项目需求: 某学校订单截止操作时间的上一个月最后一天晚上23:59:59 为止所有支付的订单统计: 代码: /// <summary> /// 通过学校和截止时间得到订单 /// < ...
- SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
相信很多人进行数据存储时,会遇上如标题的异常错误. 其实也不算上一个错误. 当你的程序中有宣告一个字段的数据类型为DateTime时,但你又没有赋值给它,就进行存储时,它就会得到这样一个结果. 看看下 ...
- android OnTouchListener 按下与抬起
写法一: private OnTouchListener pressOnTouchListener = new OnTouchListener(){ @Override public boolean ...
随机推荐
- Git典型使用场景
1. 在本地创建版本库(把本地的一个目录内的文件纳入版本库管理,方便查看变动历史,恢复版本等.不限于代码,可以是笔记等所有需要追踪历史的文件.) git init -- 把当前目录初始化为版本库 2. ...
- android:installLocation 解析
决定了apk安装位置 有三个选项:1.auto 2.internalOnly 3.preferExternal http://www.cnblogs.com/Lefter/archive/2012/0 ...
- Fragment的生命周期(三)
自定义lifecycleoffragment布局文件 在main_activity布局中引用自定义的fragment布局 到logcat中查看程勋运行的结果 代码如下: 自定义的fragment布局: ...
- SEO优化
SEO是由英文Search Engine Optimization缩写而来, 中文意译为“搜索引擎优化”.SEO是指从自然搜索结果获得网站流量的技术和过程,是在了解搜索引擎自然排名机制的基础上, 对网 ...
- VC保存当面某个区域的图片
void ViewReportDlg::CopyScreenToBitmap() { CDC *cdc = this->GetDC(); HDC wnd = cdc->GetSafeHdc ...
- Uber优步宁波司机注册正式开始啦! UBER宁波司机注册指南!
自2012年Uber开始向全球进军以来,目前已进入全球56个国家和地区的市场,在全球超过270个城市提供服务, 而Uber公司的估值已高达412亿美元. [目前开通Uber优步叫车服务的中国城市] ...
- JAVA 语法基础综合练习——学生成绩管理系统
代码如下:package com.lovo.manager; import java.util.Scanner; /** * 学生管理 * * @author Administrator * */ p ...
- LayaAir引擎——(十)
var k = new Array(); var l = new Array(); var m = new Array(); var zhiyeCurosr = 0; function zyinit( ...
- 项目中Gradle使用总结
一.配置Gradle使用Maven仓库 项目过程中,我们可能会遇到maven的本地库和gradle使用的maven本地库,不是同一个库.现在总结下怎么配置使得maven和gradle都使用相同的mav ...
- IC卡复位应答ATR解析
输入的是ATR,通过解析输出TA.TB.TC.TD的信息. 似乎没有容错处理,~~~~(>_<)~~~~ #include <stdio.h> #define TA_BIT ( ...