标签:class ada fine 内容 options htm 更改 begin 申请
tables:itab.
TYPE-POOLS: slis. "alv
"ALV显示标准定义
DATA: g_repid LIKE sy-repid,
it_fieldcat TYPE lvc_t_fcat WITH HEADER LINE,
is_layout TYPE lvc_s_layo.
DATA: gwk_grid_setting LIKE lvc_s_glay. "标记选中列
CONSTANTS pf_status TYPE slis_formname VALUE ‘ALV_PF_STATUS‘. "定义状态
CONSTANTS user_command TYPE slis_formname VALUE ‘ALV_USER_COMMAND‘. "定义按钮
"以上的都是标准的定义,直接复制。
"定义内表
DATA : BEGIN OF wa_itab,
"alv显示字段
matnr TYPE zewmt026-matnr,
END OF wa_itab.
DATA lt_itab LIKE TABLE OF wa_itab.
"可以自己定义一个小的屏幕,也可以不需要 ,看自己需不需要
SELECTION-SCREEN: BEGIN OF BLOCK b1 WITH FRAME TITLE TEXT-901.
SELECTION-SCREEN FUNCTION KEY 1.
PARAMETERS : p1 TYPE char1 RADIOBUTTON GROUP g1 .
SELECT-OPTIONS:
s_a FOR table-a ,
s_b FOR table-b .
PARAMETERS : p2 TYPE char1 RADIOBUTTON GROUP g1.
SELECTION-SCREEN: END OF BLOCK b1.
"判断自己是否需要选择屏幕,根据选择条件显示的内容
PARAMETERS d LIKE table-d.
SELECT-OPTIONS:
a FOR table-a,
b FOR table-b.
INITIALIZATION. "加载前的事件,不一定会有。
"用FORM的形式可以避免整个程序出错,还可以更快找到不正确的地方。
START-OF-SELECTION.
PERFORM get_data. "获取数据
PERFORM alv_layout_build. "alv格式设置
PERFORM alv_fieldcat. "样式
PERFORM alv_show. "ALV显示
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM get_data ." 获取需要显示的数据
SELECT *
FROM table
INTO CORRESPONDING FIELDS OF TABLE lt_itab
WHERE a IN a
AND b IN b.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_LAYOUT_BUILD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_layout_build ."自己可以添加需要的设置
is_layout-zebra = ‘X‘. "明亮显示
is_layout-box_fname = ‘SEL‘. "可选
is_layout-cwidth_opt = ‘X‘. "自动宽度
gwk_grid_setting-edt_cll_cb = ‘X‘."刷新
ENDFORM.
*&---------------------------------------------------------------------*
*& Form ALV_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM alv_fieldcat .
CLEAR it_fieldcat.REFRESH it_fieldcat.
DEFINE lit_fieldcat. "自己可以添加需要的设置
it_fieldcat-tabname = ‘IT_OUT‘.
it_fieldcat-fieldname = &1. "字段名字
it_fieldcat-coltext = &2. "字段描述
it_fieldcat-just = &3. "对齐
it_fieldcat-edit = &4. "可以更改
" ls_fieldcat-decimals_out = &5. "去掉小数点后面的零填0
.
.
.
.
APPEND it_fieldcat.
CLEAR it_fieldcat.
END-OF-DEFINITION. "lit_fieldcat
lit_fieldcat :
‘MATNR‘ ‘物料编码‘ ‘L‘ ‘‘