abap alv multiple header using write
A standard SAP ALV list report will show only one line header, but there will be a requirement someday for you to create a multiple lines header in your ALV list report and in order to do this, you must first set the no_colhead
property to “X” in the ALV Layout, this code is to exclude the standard ALV columns and after that we replace the columns text by using WRITE command at the top of page event.
Okay now let’s create a small ALV report that will display multiple lines header.
1. Execute TCODE SE38, and name the program Zmultipleheader
2. Copy and paste this code below.
*&---------------------------------------------------------------------*
*& Report ZMULTIPLEHEADER
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZMULTIPLEHEADER.
TYPE-POOLS: slis, icon.
DATA: ld_fieldcat TYPE slis_fieldcat_alv.
DATA: t_alv_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE,
Alv_Layout TYPE SLIS_LAYOUT_ALV .
DATA : it_fld TYPE slis_t_fieldcat_alv ,
it_evt TYPE slis_t_event ,
wa_fld TYPE slis_fieldcat_alv ,
wa_evt TYPE slis_alv_event ,
wa_lay TYPE slis_layout_alv .
data:
BEGIN OF itab OCCURS 0,
carrid like sflight-carrid,
connid like sflight-connid,
planetype like sflight-planetype,
seatsmax like sflight-seatsmax,
END OF itab.
START-OF-SELECTION.
"We are using table sflight to populate the internal
"table
SELECT carrid connid planetype seatsmax
FROM sflight
INTO TABLE itab.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
IMPORTING
et_events = it_evt.
READ TABLE it_evt INTO wa_evt
WITH KEY name = slis_ev_after_line_output .
wa_evt-form = slis_ev_after_line_output .
MODIFY it_evt FROM wa_evt INDEX sy-tabix .
READ TABLE it_evt INTO wa_evt
WITH KEY name = slis_ev_top_of_page .
wa_evt-form = slis_ev_top_of_page .
MODIFY it_evt FROM wa_evt INDEX sy-tabix .
CLEAR: ld_fieldcat.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'CARRID'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CLEAR: ld_fieldcat.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'CONNID'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CLEAR: ld_fieldcat.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'PLANETYPE'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
CLEAR: ld_fieldcat.
ld_fieldcat-tabname = 'ITAB'.
ld_fieldcat-fieldname = 'SEATSMAX'.
ld_fieldcat-ref_tabname = 'SFLIGHT'.
ld_fieldcat-outputlen = '10'.
APPEND ld_fieldcat TO t_alv_fieldcat.
CLEAR ld_fieldcat.
"This is where we exclude the standard ALV columns
ALV_LAYOUT-no_colhead = 'X' .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
IS_LAYOUT = ALV_LAYOUT
i_bypassing_buffer = 'X'
i_callback_program = sy-repid
it_fieldcat = t_alv_fieldcat[]
it_events = it_evt
i_save = 'A'
TABLES
t_outtab = ITAB. "internal table
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FORM top_of_page .
"Uline for creating a horizontal line
ULINE AT 1(45) .
"Format color for header background
FORMAT COLOR 7 .
"This is where we manually create the header text,
"in this example I'm using 2 lines header, if you
"want to have 3 lines header or more, you can just
"add new write command.
WRITE: / sy-vline , 02 'CARRID AND CONNID',
23 SY-VLINE, 25 'PLANE & SEATS MAX', 45 SY-VLINE.
WRITE: / sy-vline , 02 'CARRID' ,12 sy-vline, 14 'CONNID',
23 SY-VLINE, 25 'PLANE ', 34 SY-VLINE, 36 'SEATS MAX', 45 SY-VLINE.
ENDFORM.
3. Here’s the multiple header result.
abap alv multiple header using write的更多相关文章
- 【ABAP系列】SAP ABAP ALV里日期类型的F4帮助
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP ABAP ALV里日期类 ...
- 【ABAP系列】SAP ABAP ALV合计或者小计 添加自定义文本
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP ABAP ALV合计或者小计 ...
- 【ABAP系列】SAP ABAP ALV中设置CHECKBOX同时选中事件
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP ABAP ALV中设置CHE ...
- 【ABAP系列】SAP ABAP ALV设置背景图片
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP abap ALV设置背景图片 ...
- 【ABAP系列】SAP ABAP ALV中的TOP_OF_PAGE添加任意图标
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[MM系列]SAP ABAP ALV中的TOP_ ...
- ABAP ALV单个单元格状态编辑
*&---------------------------------------------------------------------* *& Report ZPPR0024 ...
- ABAP ALV 颜色设置(行,列,单元格)
BCALV_EDIT_03 http://blog.sina.com.cn/s/blog_a87b19300102who3.html 关于ALV表格颜色,这种需求在项目中会经常用到. 列颜色 列的颜色 ...
- ABAP ALV DEMO示例源码
关于ALV表格颜色,感觉这种需求在项目中用到的时候不是很多,但是前一段时间面试的时候,面试官问了我关于ALV单元格颜色的问题. 以前了解过一点,回答的不是很好,后来百度了一下,大概了解了一些,今天工作 ...
- ABAP ALV表头的实现
ABAP实现ALV表头的DEMO: 效果: 源代码: *&------------------------------------------------------------------- ...
随机推荐
- webservice asmx 无法序列化接口 System.Collections.Generic.IList
转载自:http://www.cnblogs.com/chenhuzi/p/4178194.html 今天有位同事在方法里加了一个IList<entity> 的返回值,也没有测试,直接发布 ...
- 11181 - Probability|Given
N friends go to the local super market together. The probability of their buying something from them ...
- 20款Notepad++插件下载和介绍
转自:http://www.kuqin.com/developtool/20090628/59334.html Notepad++从3.4版本开始支持插件机制,让用户可选择的为本身已经优秀的Notep ...
- zoj 1730 / poj 1455 Crazy Tea Party
这阵子都没怎么写代码,由于开学,忙于各种琐碎的事情,现在静下来了开始跟着暑假的节奏刷题了. 这道题一开是没看清题目-在寝室刷题就是效率不高... 后来才知道,题目意思是,一个环形序列,1minute可 ...
- c++中一个类所占用的空间
看到阿里的一道笔试题: #pragma pack(2) class A { int i; union U { char buff[13]; int i; }u; void foo() { } type ...
- 在Ubuntu下编译Assimp库
在Ubuntu下编译Assimp库 怎样在Ubuntu下编译Assimp库?这是我曾经编译成功后做的笔记,供參考. 1.去以下的站点去下载Assimp库: http://assimp.sourcefo ...
- MSSQL - 多表查询
SELECT u.UserNumber, u.UserName, c.CarNumber, c.CarName, c.CarEngine, s.BuyLs, s.BuyTime FROM Tb_Sal ...
- linux脚本:shell, 判断输入参数的个数(命令行)
if [ $# != 3 ] ; thenecho "USAGE: $0 from to"echo " e.g.: $0 ~/oucaijun/from ~/oucaij ...
- Java内部类——成员内部类
成员内部类的意思就是,一个外层类里面包含着一个非static的class,举例如下: class OuterClass { //变量,函数定义... class InnerClass { //变量,函 ...
- Tesseract Ocr引擎
Tesseract Ocr引擎 1.Tesseract介绍 tesseract 是一个google支持的开源ocr项目,其项目地址:https://github.com/tesseract-ocr/t ...