首页 > 其他分享 >ZCL_QALV_DISPLAY

ZCL_QALV_DISPLAY

时间:2023-05-18 23:15:40浏览次数:46  
标签:event gt ZCL ALVID spfli ALV Importing QALV DISPLAY

Introduction

Class: ZCL_QALV_DISPLAY

  • ALV簡化用法(純Display,不可進edit mode)

History

VersionDateNameDescription
V001 2020/10/13 Huang Roy 初版
V002 2020/11/30 Huang Roy Event新增動態call method
V003 2020/12/24 Huang Roy 繼承ZCL_QALV method
V004 2021/1/14 Huang Roy 新增預設sort & filter

Public Method

GRID_TABNAME

  • ALV Field Catalog from Table Name
  • I_ALVID: 預設為 'QALV',一般情況下不需用不同值,但同一程式有多張報表時,記得要區分開(因ALV Variant是以Program Name + ALVID存檔)
  • I_TITLE: 預設與SY-TITLE相同,可自行修改
  • IS_LAYOUT: 需自訂才使用
  • IS_VARIANT: 需自訂才使用
  • IT_EXTOOL: 設定不使用的Toolbar function
  • I_LEFT/I_TOP/I_RIGHT/I_BOTTOM: 視窗化顯示使用
  • IS_EVENT: event register,後面範例再說明
  • CT_OUT: 輸出資料
ParameterLevelPass ValueOptionalType(Ref To)DefaultDescription
I_TABNAME Importing     TABNAME   Table Name
I_ALVID Importing   X SLIS_HANDL C_DEFAULT_ALVID ALV ID
I_TITLE Importing   X SYTITLE SY-TITLE Contents of Title Line
IS_LAYOUT Importing   X LVC_S_LAYO   ALV control
IS_VARIANT Importing   X SLIS_VARI   Layout(HANDLE = ALV ID)
IT_EXTOOL Importing   X UI_FUNCTIONS   Exclude ALV Toorbar
IT_SORT Importing   X LVC_T_SORT   Default Sort V004 add
IT_FILTER Importing   X LVC_T_FILT   Default Filter V004 add
I_LEFT Importing   X I   Start Column
I_TOP Importing   X I   Start Line
I_RIGHT Importing   X I   End Column
I_BOTTOM Importing   X I   End Line
IS_EVENT Importing   X TY_EVENT   Register Event(FORM: _EVENT_<event name>)
CT_OUT Changing     STANDARD TABLE   Table for ALV output

Sample

Click to Expand Code
DATA gt_spfli TYPE TABLE OF spfli.

START-OF-SELECTION.
  SELECT *
    INTO TABLE gt_spfli
    FROM spfli.
  zcl_qalv_display=>grid_tabname( EXPORTING i_tabname = 'SPFLI'
                                   CHANGING ct_out    = gt_spfli ).

Result


GRID_ALVID

  • ALV Field Catalog from table: ZTQALV_FCAT by ALVID
  • 參數說明,參考Method: GRID_TABNAME
ParameterLevelPass ValueOptionalType(Ref To)DefaultDescription
I_ALVID Importing   X SLIS_HANDL C_DEFAULT_ALVID ALV ID
I_TITLE Importing   X SYTITLE SY-TITLE Contents of Title Line
IS_LAYOUT Importing   X LVC_S_LAYO   ALV control
IS_VARIANT Importing   X SLIS_VARI   Layout(HANDLE = ALV ID)
IT_EXTOOL Importing   X UI_FUNCTIONS   Exclude ALV Toorbar
IT_SORT Importing   X LVC_T_SORT   Default Sort V004 add
IT_FILTER Importing   X LVC_T_FILT   Default Filter V004 add
I_LEFT Importing   X I   Start Column
I_TOP Importing   X I   Start Line
I_RIGHT Importing   X I   End Column
I_BOTTOM Importing   X I   End Line
IS_EVENT Importing   X TY_EVENT   Register Event(FORM: _EVENT_<event name>)
CT_OUT Changing     STANDARD TABLE   Table for ALV output
  • 依ALVID設定格式於Table: ZTQALV_FCAT,因為預設是 'QALV',故這裡將ALVID填入'QALV',Program就填Program Name

Sample

Click to Expand Code
DATA gt_spfli TYPE TABLE OF spfli.

START-OF-SELECTION.
  SELECT *
    INTO TABLE gt_spfli
    FROM spfli.
  zcl_qalv_display=>grid_alvid( CHANGING ct_out = gt_spfli ).

Result


GRID_CUST

  • Customize ALV Field Catalog
  • CT_FCAT: 自訂Field Catalog
  • 其他參數說明,參考Method: GRID_TABNAME
ParameterLevelPass ValueOptionalType(Ref To)DefaultDescription
I_ALVID Importing   X SLIS_HANDL C_DEFAULT_ALVID ALV ID
I_TITLE Importing   X SYTITLE SY-TITLE Contents of Title Line
IS_LAYOUT Importing   X LVC_S_LAYO   ALV control
IS_VARIANT Importing   X SLIS_VARI   Layout(HANDLE = ALV ID)
IT_EXTOOL Importing   X UI_FUNCTIONS   Exclude ALV Toorbar
IT_SORT Importing   X LVC_T_SORT   Default Sort V004 add
IT_FILTER Importing   X LVC_T_FILT   Default Filter V004 add
I_LEFT Importing   X I   Start Column
I_TOP Importing   X I   Start Line
I_RIGHT Importing   X I   End Column
I_BOTTOM Importing   X I   End Line
IS_EVENT Importing   X TY_EVENT   Register Event(FORM: _EVENT_<event name>)
CT_OUT Changing     STANDARD TABLE   Table for ALV output
CT_FCAT Changing     LVC_T_FCAT   Field Catalog for List Viewer Control

Sample

Click to Expand Code
DATA: gt_spfli TYPE TABLE OF spfli,
      gw_fcat TYPE lvc_s_fcat,
      gt_fcat TYPE lvc_t_fcat.

START-OF-SELECTION.
  SELECT *
    INTO TABLE gt_spfli
    FROM spfli.
  gw_fcat-fieldname = 'CARRID'.
  gw_fcat-coltext = 'Airline Code'.
  APPEND gw_fcat TO gt_fcat.
  gw_fcat-fieldname = 'AIRPFROM'.
  gw_fcat-coltext = 'Departure airport'.
  APPEND gw_fcat TO gt_fcat.
  zcl_qalv_display=>grid_cust( CHANGING ct_out  = gt_spfli
                                        ct_fcat = gt_fcat  ).

Result


GET_VARIANT

  • 依ALVID取得ALV Variant Name(Inherit from ZCL_QALV) V003 add
  • ※Program使用SY-CPROG
ParameterLevelPass ValueOptionalType(Ref To)DefaultDescription
I_ALVID Importing   X SLIS_HANDL C_DEFAULT_ALVID ALV ID
R_VARIANT Returning X   SLIS_VARI   ALV variant

GET_FCAT_TABNAME

  • 將Table or Structure轉為ALV Field Catalog(Inherit from ZCL_QALV) V003 add
ParameterLevelPass ValueOptionalType(Ref To)DefaultDescription
I_TABNAME Importing     TABNAME   Table Name
RT_FCAT Returning X   LVC_T_FCAT   Field Catalog for List Viewer Control

GET_FCAT_ALVID

  • 依Program + ALVID取得ALV Field Catalog(Inherit from ZCL_QALV) V003 add
  • 設定Table: ZTQALV_FCAT
ParameterLevelPass ValueOptionalType(Ref To)DefaultDescription
I_PROG Importing   X PROGRAM_ID SY-CPROG Program Name
I_ALVID Importing   X SLIS_HANDL C_DEFAULT_ALVID ALV ID
RT_FCAT Returning X   LVC_T_FCAT   Field Catalog for List Viewer Control

CONTAINER_FACTORY

  • 產生Container物件,可忽略,Display沒開放使用(Inherit from ZCL_QALV) V003 add

EVENT

  • 只把比較常用的event開放在此:
EventDescription
context_menu_request 滑鼠右鍵
double_click 雙擊滑鼠左鍵
hotspot_click 點擊hotspot欄位
menu_button 點擊自訂menu toolbar
onf1 點擊F1
toolbar ALV第一次進入,toolbar事件,可在此增加自訂按鈕
user_command 點擊自訂按鈕

Sample

  • 這裡以GRID_TABNAME執行double click動作說明,其他event使用方式一樣。
  • IS_EVENT: 傳入需要註冊事件的清單(ABAP_TRUE)
  • Trigger event兩種寫法,一種Class(V002 add), 一種Form(Class優先,不存在則使用Form)
  • Local Class: 固定用lcl_grid_event,method使用event name(記得用public static method)
  • FORM: 統一在event name前加上g_(GRID)。
  • 尋找 Event Parameter: 至Class ZCL_QALV_GRID找到相對應event,即可找到傳入的參數(其實就是alvid加上原始event傳入參數,alvid用以輔助判斷目前trigger event的是哪個alv object)
Click to Expand Code

CLASS

CLASS lcl_grid_event DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS double_click IMPORTING i_alvid TYPE any
                                         is_row TYPE lvc_s_row
                                         is_column TYPE lvc_s_col
                                         is_row_no TYPE any.
ENDCLASS.
CLASS lcl_grid_event IMPLEMENTATION.
  METHOD double_click.
    DATA l_msg TYPE string.
    l_msg = |ALVID: { i_alvid }, DoubleClick, Row: { is_row-index },| &&
            | Column: { is_column-fieldname }|.
    MESSAGE l_msg TYPE 'I'.
  ENDMETHOD.
ENDCLASS.
DATA: gt_spfli TYPE TABLE OF spfli,
      gw_event TYPE zcl_qalv_display=>ty_event.

START-OF-SELECTION.
  SELECT *
    INTO TABLE gt_spfli
    FROM spfli.
  gw_event-double_click = abap_true.
  zcl_qalv_display=>grid_tabname( EXPORTING i_tabname = 'SPFLI'
                                            is_event  = gw_event
                                   CHANGING ct_out    = gt_spfli ).

FORM

DATA: gt_spfli TYPE TABLE OF spfli,
      gw_event TYPE zcl_qalv_display=>ty_event.
START-OF-SELECTION.
  SELECT *
    INTO TABLE gt_spfli
    FROM spfli.
  gw_event-double_click = abap_true.
  zcl_qalv_display=>grid_tabname( EXPORTING i_tabname = 'SPFLI'
                                            is_event  = gw_event
                                   CHANGING ct_out    = gt_spfli ).
FORM g_double_click USING alvid
                          e_row TYPE lvc_s_row
                          e_column TYPE lvc_s_col
                          es_row_no.
  DATA l_msg TYPE string.
  l_msg = |ALVID: { alvid }, DoubleClick, Row: { e_row-index },| &&
          | Column: { e_column-fieldname }|.
  MESSAGE l_msg TYPE 'I'.
ENDFORM. 

Result(兩種方法一樣)


技術提供: Gitea 版本: 1.15.5 頁面: 430ms 樣板: 0ms   繁體中文(台灣)  授權條款 API 網站 Go1.16.9

标签:event,gt,ZCL,ALVID,spfli,ALV,Importing,QALV,DISPLAY
From: https://www.cnblogs.com/TYAING/p/17413562.html

相关文章

  • ZCL_REST_CLIENT
    IntroductionHistoryPublicMethodHANDLE_REQUESTProtectedMethod_HANDLE_REQUESTSample建立RESTfulAPIClass設定API路徑LogsAppendixSMICM各環境HostName,PortIntroductionZCL_REST_CLIENTRESTful-APIconsumerenhancement-自動記錄reque......
  • ZCL_REST_SERVER
    IntroductionHistoryPublicMethodIF_HTTP_EXTENSION~HANDLE_REQUESTProtectedMethod_HANDLE_REQUESTSample建立RESTful-APIClass設定API路徑LogsAppendixSMICM各環境HostName,PortIntroductionZCL_REST_SERVERRESTful-APIproviderenhanceme......
  • ZCL_REST_SYSTEM_MONITOR
    IntroductionHistorySwaggerIntroductionClass:ZCL_REST_SYSTEM_MONITOR利用zcl_tools=>get_system_monitor(),給外部取得SAP系統狀況HistoryVersionDateNameDescriptionV0012021/10/13HuangRoy初版SwaggerItemURLSwaggerUIhttp://tao-misdb......
  • Zclip:复制页面内容到剪贴板兼容各浏览器
    WEB开发中,要让用户复制页面中的一段代码、URL地址等信息,为了避免用户拖动鼠标再进行右键复制操作而可能出现的差错,我们可以直接在页面中放置一个复制按钮,只需要轻轻一点这个复制按钮,内容将会被复制,然后用户可以粘贴到想粘贴的地方。 本文将结合实例讲解如何使用一款基于jQuery的插......
  • How to connect to multiple SSD1306 OLED Displays using Raspberry Pi GPIO I2C PIN
    HowtoconnecttomultipleSSD1306OLEDDisplaysusingRaspberryPiGPIOI2CPINAllInOne如何使用RaspberryPi的GPIOI2CPIN连接多个SSD1306OLED显示器demos(......
  • Raspberry Pi & 0.96 inch OLED display All In One
    RaspberryPi&0.96inchOLEDdisplayAllInOneI2CGPIOPythondemos(......
  • OrchardCore 中的 插件开发/ Shape / DisplayDriver / 视图扩展 / Razor代码注入
    请注意该文章仅限于OrchardCore项目中的DisplayDriver扩展机制,ASP.NETCOREMVC自身并没有对应功能,如果需要可以将相关的OrchardCore模块添加到项目中也可以实现响应功能背景最近一个功能需求,需要使用其它用户模拟身份,所以计划在用户列表页面扩展按钮组功能那么开始看代......
  • 使用nacos配置,启动服务时一直报 Error starting ApplicationContext. To display the
    报错日志如下:ErrorstartingApplicationContext.Todisplaytheconditionsreportre-runyourapplicationwith'debug'enabled.-2023-05-0509:46:02.328[TID:N/A]ERROR8236---[main]o.s.b.d.LoggingFailureAnalysisReporter:***********......
  • vue学习 第九天(1) 元素的显示与隐藏 display (不保留位置) / visibility (保留位置) /
    元素的显示与隐藏本质:让一个元素在页面中隐藏或者显示出来。1、display属性,隐藏后不保留位置1)display::none;隐藏对象2)display:block;除了转换为块级元素之外,同时还有显示元素的意思。display隐藏元素后,不再占有原来的位置。 2......
  • 什么是弹性(display: flex)布局 ?
    display:flex意思是弹性布局,它能够扩展和收缩flex容器内的元素,以最大限度地填充可用空间。Flex是FlexibleBox的缩写,意为”弹性布局”,用来为盒状模型提供最大的灵活性。任何一个容器都可以指定为Flex布局。.box{display:flex;}注意,设为Flex布局以后,子元素的flo......