下面介绍如何在ALV头中显示Logo图片的方法,其中ALV是调用函数REUSE_ALV_GRID_DISPLAY创建的。详细步骤如下:
1, OAER上载Logo
Tcode: OAER上载需要显示的LOGO图片,
输入Class name ’PICTURERS',Class type以及Object key ‘ZLOGO',这个ZLOGO就是logo的标识,会在ALV程序中用到。
运行后,双击screen上载logo
输入描述,
上载成功后会有如下提示信息:
2, 例子代码
代码逻辑:
1,从SPFLI中抽取数据
2,调用REUSE_ALV_GRID_DISPLAY创建ALV,需要指定 i_callback_top_of_page参数
3,在回调函数top_of_page中,调用 REUSE_ALV_COMMENTARY_WRITE指定显示logo的object ID 'ZLOGO'.
完整代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
REPORT ztest_alv_logo. TYPE-POOLS: slis. *----------------------------------------------------------------------* * Data Decalaration *----------------------------------------------------------------------* DATA: git_spfli TYPE TABLE OF spfli. DATA: g_repid TYPE sy-repid. DATA: git_listheader TYPE slis_t_listheader, gwa_listheader TYPE slis_listheader. *----------------------------------------------------------------------* * START-OF-SELECTION *----------------------------------------------------------------------* START-OF-SELECTION. g_repid = sy-repid. SELECT * FROM spfli INTO TABLE git_spfli. PERFORM build_alv_header. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_callback_program = g_repid i_callback_top_of_page = 'TOP_OF_PAGE' i_structure_name = 'SPFLI' TABLES t_outtab = git_spfli. *&---------------------------------------------------------------------* *& Form BUILD_ALV_HEADER *&---------------------------------------------------------------------* FORM build_alv_header . * Type H is used to display headers i.e. big font gwa_listheader-typ = 'H'. gwa_listheader-info ='Flight Details'. APPEND gwa_listheader TO git_listheader. CLEAR gwa_listheader. * Type S is used to display key and value pairs gwa_listheader-typ = 'S'. gwa_listheader-key = 'Date :' . CONCATENATE sy-datum+6(2) sy-datum+4(2) sy-datum(4) INTO gwa_listheader-info SEPARATED BY '/'. APPEND gwa_listheader TO git_listheader. CLEAR gwa_listheader. * Type A is used to display italic font gwa_listheader-typ = 'A'. gwa_listheader-key = 'Date :' . gwa_listheader-info ='SAP ALV Report'. APPEND gwa_listheader TO git_listheader. CLEAR gwa_listheader. ENDFORM. " BUILD_ALV_HEADER *&---------------------------------------------------------------------* *& Form top_of_page *&---------------------------------------------------------------------* FORM top_of_page. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = git_listheader i_logo = 'ZLOGO'. "LOGO object key 大写 ENDFORM. "top_of_page |
3, 运行结果
以上。
1 条评论