就这么个东西,主要是有时候又没别的需求,就是弹出alv,每次都复制粘贴我都嫌麻烦,就写了个function,直接call就行了。
这个是弹出的,有一个不弹的,反正都类似的东西。
FUNCTION zlm_alv_popup_simple.
*"----------------------------------------------------------------------
*"*"本地接口:
IMPORTING
REFERENCE(IV_ALV_STRUCTURE)
REFERENCE(IV_GRID_TITLE) OPTIONAL
TABLES
IT_DATA
*"----------------------------------------------------------------------
DATA go_alv TYPE REF TO cl_salv_table.
DATA: go_functions TYPE REF TO cl_salv_functions_list,
go_selections TYPE REF TO cl_salv_selections,
go_layout TYPE REF TO cl_salv_layout,
go_display TYPE REF TO cl_salv_display_settings.
DATA: gr_columns TYPE REF TO cl_salv_columns_table.
DATA: gr_column TYPE REF TO cl_salv_column_table.
DATA lt_rows TYPE salv_t_row.
DATA:ls_row TYPE LINE OF salv_t_row.
DATA lv_scrtext_s TYPE scrtext_s .
DATA lv_scrtext_m TYPE scrtext_m .
DATA lv_scrtext_l TYPE scrtext_l .
DATA lv_feild TYPE lvc_fname.
DATA lv_title TYPE lvc_title.
DATA:lt_fieldcat TYPE lvc_t_fcat.
DATA:ls_layout TYPE slis_layout_alv.
DATA:lt_fieldcatalog TYPE slis_t_fieldcat_alv .
DATA:lv_grid_title TYPE lvc_title .
DATA:lv_alv_structure TYPE dd02l-tabname .
DATA lines TYPE int4.
*-------------------------------------------------------------------*
" 方法生成的ALV容器对象
*-------------------------------------------------------------------*
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = go_alv"方法生成的ALV容器对象
CHANGING
t_table = it_data[] )."alv展示的数据
CATCH cx_salv_msg.
ENDTRY.
*-------------------------------------------------------------------*
" 基础设置
*-------------------------------------------------------------------*
lv_title = iv_grid_title.
go_functions = go_alv->get_functions( ).
'X' )."设置默认按键
go_selections = go_alv->get_selections( ).
if_salv_c_selection_mode=>single )."设置选择模式
go_display = go_alv->get_display_settings( ).
'X' )."列自适应
value = lv_title ).
gr_columns = go_alv->get_columns( ).
'X' ).
*-------------------------------------------------------------------*
" 循环处理列
*-------------------------------------------------------------------*
lv_alv_structure = iv_alv_structure.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = lv_alv_structure
CHANGING
ct_fieldcat = lt_fieldcatalog
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
RETURN.
ENDIF.
LOOP AT lt_fieldcatalog INTO DATA(ls_fieldcata).
lv_scrtext_s = lv_scrtext_m = lv_scrtext_l = ls_fieldcata-seltext_l.
lv_feild = ls_fieldcata-fieldname.
gr_column ?= gr_columns->get_column( lv_feild )."需处理的列
lv_scrtext_l ).
lv_scrtext_m ).
lv_scrtext_s ).
ENDLOOP.
*-------------------------------------------------------------------*
" 展示
*-------------------------------------------------------------------*
IF go_alv IS BOUND.
go_alv->set_screen_popup(
start_column = 10
end_column = 110
start_line = 5
end_line = 15 ).
). "调用显示方法
ENDIF.
ENDFUNCTION.
就是懒得每次都复制粘贴而已,直接call吧,别的功能没有,需要的自己完善就行。
好啦,故事到此为止,随手记录一下。
推荐阅读:
《ABAP新语法1》
《关于 SM30/VIEW_MAINTENANCE_CALL锁整张表问题》
《使用cl_gui_docking_container 实现多ALV》
《DEMO:S/4 1809 FAGLL03H 增加字段增强》
《几个ABAP实用模板,体力活就别一行行敲了,复制粘贴得了》
《SAP Parallel Accounting(平行分类账业务)配置+操作手册+BAPI demo程序》
《CC02修改确认日期BAPI:Processing of change number was canceled》《我是怎样调试BAPI的,以F-02为例》
《苏州游记》
《杂谈:几种接口》
《RESTful DEMO 一:SAP 如何提供 RESTful Web 服务》
《DEMO search help 增强 ( vl03n KO03 等)》
Debug 系列