ABAP屏幕容器ALV显示
FORM frm_display_alv .
IF gcl_alv IS INITIAL.
CREATE OBJECT: gcl_container'屏幕容器,下面不用默认屏幕则需要在屏幕画自定义控件
EXPORTING
container_name = 'ALV_COMM'.
CREATE OBJECT gcl_alv'容器实例
EXPORTING
i_parent = gcl_container.
CALL METHOD gcl_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD gcl_alv->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_modified.
*准备获取字段目录,主要针对每个字段
PERFORM frm_prepare_fieldcat.' CHANGING gt_fieldcat.
*准备设置布局,整体布局
PERFORM frm_prepare_layout CHANGING gs_layout.
*排除不需要的标准按钮container容器用法
PERFORM frm_exclude_toolbar CHANGING gt_excluding.
*显示ALV
CALL METHOD gcl_alv->set_table_for_first_display
EXPORTING
* I_BUFFER_ACTIVE = 'X''静态调用,每次相同字段目录可设为X,可加速显示ALV
* I_CONSISTENCY_CHECK =
* i_structure_name = 'SFLIGHT''若无字段目录,则必须设置此选项
* is_variant = gs_variant
i_save = 'A''X全局,U特定,A两者变式,SPACE均不可保存
i_default = 'X''是否可定义默认布局
is_layout = gs_layout
* IS_PRINT ='打印内表
* IT_SPECIAL_GROUPS ='字段目录设置了SP_GROUP被分组在一起的内表
it_toolbar_excluding = gt_excluding
* it_hyperlink = gt_hyperlink
CHANGING
it_outtab = it_tab_alv[]'显示内表最好和字段目录一样结构
it_fieldcatalog = gt_fieldcat
'it_sort = gt_sort'排序
'it_filter = gt_filter'过滤
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
PERFORM frm_register_events.
ELSE .
*----刷新ALV
CALL METHOD gcl_alv->refresh_table_display
* EXPORTING
* IS_STABLE =
* I_SOFT_REFRESH =
EXCEPTIONS
finished = 1
OTHERS = 2 .
' IF sy-subrc <> 0.
*--异常处理
' ENDIF.
ENDIF .
ENDFORM. ' FRM_DISPLAY_ALV
*&---------------------------------------------------------------------*
*& Form FRM_MODIFY_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
' FRM_MODIFY_ALV
*&---------------------------------------------------------------------*
*& Form FRM_PREPARE_FIELDCAT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GT_FIELDCAT text
*----------------------------------------------------------------------*
FORM frm_prepare_fieldcat .' CHANGING p_gt_fieldcat TYPE lvc_t_fcat.
add_field:
'SPART' 'IT_TAB_ALV' 8 '业务单元',
'MATNR' 'IT_TAB_ALV' 20 '我司商品编码',
'MAKTX' 'IT_TAB_ALV' 25 '我司商品描述',
'CITY_CODE' 'IT_TAB_ALV' 12 '我司城市编码',
'CITY_NAME' 'IT_TAB_ALV' 20 '我司城市名称',
'COMPETITOR_NAME' 'IT_TAB_ALV' 10 '竞争对手名称',
'ZCITY_NAME' 'IT_TAB_ALV' 20 '竞争对手城市名称',
'COMPETITOR_LISTING_PRICE' 'IT_TAB_ALV' 10 '挂牌价价格',
'COMPETITOR_DEAL_PRICE' 'IT_TAB_ALV' 10 '购物车价格',
'AVAILABLE' 'IT_TAB_ALV' 8 '对手是否有货',
'ISBN_NO' 'IT_TAB_ALV' 18 'ISBN编码',
'CATCH_DATE' 'IT_TAB_ALV' 10 '抓取日期',
'CMMDTY_TIME' 'IT_TAB_ALV' 8 '抓取时间',
'BGAUTHOR' 'IT_TAB_ALV' 12 '修改者'.
ENDFORM. ' FRM_PREPARE_FIELDCAT
*&---------------------------------------------------------------------*
*& Form FRM_PREPARE_LAYOUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_GS_LAYOUT text
*----------------------------------------------------------------------*
FORM frm_prepare_layout CHANGING ps_layout TYPE lvc_s_layo.
ps_layout-zebra = 'X'.
ENDFORM. ' FRM_PREPARE_LAYOUT
*&---------------------------------------------------------------------*
*& Form FRM_REGISTER_EVENTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论