标签:字段排序 line display test ons event pac abi ble
2019-10-09
用 ALV 输出的基本流程:
CALL FUNCTION ‘REUSE_ALV_EVENTS_GET‘ "获得事件名称及 form 的内表, 后面去填补 form"
EXPORTING
i_list_type = 0
IMPORTING
et_events = i_events.
READ TABLE i_events WITH KEY name = slis_ev_top_of_page INTO w_events.
IF sy-subrc = 0.
MOVE ‘ALV_TOP_OF_PAGE‘ TO w_events-form. "将标题区数据赋值给 W_EVENTS
MODIFY i_events FROM w_events INDEX sy-tabix.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_end_of_list INTO w_events.
IF sy-subrc = 0.
MOVE ‘ALV_END_OF_LIST‘ TO w_events-form. "将页尾数据赋值给 W_EVENTS
MODIFY i_events FROM w_events INDEX sy-tabix.
ENDIF.
READ TABLE i_events WITH KEY name = slis_ev_end_of_page INTO w_events.
IF sy-subrc = 0.
MOVE ‘ALV_END_OF_PAGE‘ TO w_events-form. "将页脚区数据赋值给 W_EVENTS.
MODIFY i_events FROM w_events INDEX sy-tabix.
ENDIF.
ENDFORM.
DATA: p_werks(40).
CLEAR: i_list_comments[].
w_list_comments-typ = ‘H‘. "H=Header, S=Selection, A=Action
w_list_comments-key = ‘‘.
w_list_comments-info = ‘USI 同一 PO 分批收料报表‘.
APPEND w_list_comments TO i_list_comments.
* w_list_comments-typ = ‘S‘. "H = Header, S = Selection, A = Action
* w_list_comments-key = ‘‘.
* CONCATENATE ‘厂别‘ ‘1000‘ INTO p_werks.
* w_list_comments-info = p_werks.
* APPEND w_list_comments TO i_list_comments.
*
* w_list_comments-typ = ‘S‘. "H = Header, S = Selection, A = Action
* w_list_comments-key = ‘‘.
* CONCATENATE ‘厂别‘ ‘2000‘ INTO p_werks.
* w_list_comments-info = p_werks.
* APPEND w_list_comments TO i_list_comments.
CALL FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE‘
EXPORTING
i_logo = ‘ENJOYSAP_LOGO‘
it_list_commentary = i_list_comments.
ENDFORM. "alv_top_of_page
*&---------------------------------------------------------------------*4. Layout设置
*& Form alv_end_of_list
*&---------------------------------------------------------------------*
FORM alv_end_of_list.
clear: i_list_comments[].
w_list_comments-typ = ‘H‘. "H=Header, S=Selection, A=Action
w_list_comments-key = ‘‘.
w_list_comments-info = ‘页脚显示‘.
APPEND w_list_comments to i_list_comments.
call FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE‘
EXPORTING
it_list_commentary = i_list_comments
i_logo = ‘ENJOYSAP_LOGO‘
i_end_of_list_grid = ‘X‘.
ENDFORM. "alv_end_of_list
*&---------------------------------------------------------------------*
*& Form alv_end_of_page
*&---------------------------------------------------------------------*
FORM alv_end_of_page.
* CLEAR: i_list_comments[].
* w_list_comments-typ = ‘A‘. "H=Header, S=Selection, A=Action
* w_list_comments-key = ‘‘.
* w_list_comments-info = ‘END OF PAGE‘.
* APPEND w_list_comments TO i_list_comments.
*
* CALL FUNCTION ‘REUSE_ALV_COMMENTARY_WRITE‘
* EXPORTING
* it_list_commentary = i_list_comments
* i_logo = ‘ENJOYSAP_LOGO‘
* i_end_of_list_grid = ‘X‘.
ENDFORM. "alv_end_of_page
FORM layout_build .w_repid = sy-repid. "当前程式i_layout-zebra = ‘X‘. "斑马条纹间隔i_layout-colwidth_optimize = ‘X‘. "优化列宽* i_layout-no_vline = ‘X‘. "用来设置是否有列间隔线i_layout-detail_initial_lines = ‘X‘.i_layout-detail_titlebar = ‘详细内容‘. "设置弹出窗口的标题栏i_layout-detail_popup = ‘X‘. "是否弹出详细信息窗口i_layout-f2code = ‘&ETA‘. "设置触发弹出详细窗口的功能码,这里是双击* i_layout-info_fieldname = ‘COLOR‘ ."设置颜色属性,设置ALV输出报表每一行的颜色,"其参数为输出内表的栏位名称,要注意的是,使用
"该属性需要同时在内表中定义一个与该参数所定义
"字段相同的栏位,然后往该栏位位填值. "先介绍ALV里色码.就是颜色编码,4位CHAR型.
Cxyz---
Color X:1-7
Y:1/0: 强化 开/关
Z:1/0: 相反 开/关
其中C是固定的第一位,第二位代表是颜色编码(1到7),第三位是加强的设置,第四位是相反,个人理解,在强化关闭的情况下,相反的作用是背景和字体的变化.
颜色编码:
x 颜色 主要使用在
1 Gray-blue headers
2 Light gray List bodies
3 yellow totals
4 Blue-green Key columns
5 green Positive threshold value
6 red Negative threshold value
7 orange Control levels
ENDFORM. " LAYOUT_BUILD
w_fieldcat-col_pos = p_pos.
w_fieldcat-fieldname = p_field_name.
w_fieldcat-seltext_m = p_field_text.
w_fieldcat-emphasize = p_color. "设置列的颜色,注意:行的颜色会覆盖列的颜色
w_fieldcat-do_sum = ‘X‘. "对列求和
w_fieldcat-just = ‘R‘. "对齐试(R, L, C)
w_fieldcat-lzero = ‘X‘. "前导0的形式显示
* w_fieldcat-no_sign = ‘X‘. "将定义栏位的符号设置为不显示
* w_fieldcat-hotspot = ‘X‘. "设置栏位是否有热点
APPEND w_fieldcat TO i_fieldcat.
ENDFORM. " SET_FIELDCAT
7. 颜色的显示FORM output_alv .
CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY‘
EXPORTING
i_callback_program = w_repid
i_save = ‘A‘
i_default = ‘X‘
is_layout = i_layout
it_fieldcat = i_alv_fieldcat
it_events = i_eventsit_sort = i_sort[]i_callback_html_top_of_page = ‘DGL_HTML_TOP_OF_PAGE‘ "覆盖 i_events中定义的.
TABLES
t_outtab = it_output[]
EXCEPTIONS
program_error = 1
OTHERS = 2.
ENDFORM.
FORM set_sort .w_sort-fieldname = ‘MATKL‘.w_sort-up = ‘X‘.w_sort-group = ‘*‘.w_sort-subtot = ‘X‘.APPEND w_sort TO i_sort.ENDFORM.这样相同的那列就会合并,如果要避免合并,请在布局中设置"no_merging"为"X" .
9. ALV 标题中的表头
FORM dgl_html_top_of_page USING r_ddoc TYPE REF TO cl_dd_document.DATA: text TYPE sdydo_text_element.
CALL METHOD r_ddoc->initialize_document. "定义表头文本
DEFINE write_inf.
call method r_ddoc->new_line. "换行
call method r_ddoc->add_icon "输出图标
exporting
sap_icon = &1.
call method r_ddoc->add_text "输出文本
exporting
text = &2.
END-OF-DEFINITION.
CALL METHOD r_ddoc->add_text
EXPORTING
text = ‘Justin Test‘
sap_emphasis = ‘STRONG‘.
write_inf ‘ICON_GREEN_LIGHT‘ ‘: 商品库存‘.
write_inf ‘ICON_RED_LIGHT‘ ‘: 商品无可用库存‘.
ENDFORM.
data: m_buff TYPE string.
data: m_p TYPE i.
m_buff = ‘<html>‘.
CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p.
m_buff = ‘<center><H2>配件报废品种汇总表</H2></Center>‘.
CALL METHOD CL_DD->HTML_INSERT
EXPORTING
CONTENTS = m_buff
CHANGING
POSITION = m_p.
CONCATENATE ‘报表日期:‘ S_DATE-LOW ‘ TO ‘ S_DATE-HIGH ‘<BR>‘ into m_buff.
CALL METHOD CL_DD->HTML_INSERT
EXPORTING
CONTENTS = m_buff
CHANGING
POSITION = m_p.
m_buff = ‘</html>‘.
CALL METHOD cl_dd->html_insert
EXPORTING
contents = m_buff
CHANGING
position = m_p.
标签:字段排序 line display test ons event pac abi ble
原文地址:https://www.cnblogs.com/salah/p/11641939.html