ABAP 图片预览
在SMARTFORMS中需要打印的時候如果需要打印圖片的話一般需要手動上傳圖片到服務器上,如果批量上傳以后想預覽的話系統沒有提供標準的批量預覽的功能,只能在SE78中一個個預覽。下面介紹的也是一個個預覽的,考慮在列表中雙擊的時候展示出來。
在屏幕 9000上創建容器 ?GL_IMAGE?并處理相應的PAI和PBO事件,在PBO事件中增加一個MODULE,在其中添加如下代碼: DATA: w_lines TYPE i. TYPES pict_line(256) TYPE c. DATA : ? ?? container TYPE REF TOcl_gui_custom_container, ? ?? editor TYPE REF TO cl_gui_textedit, ? ?? picture TYPE REF TO cl_gui_picture, ? ?? pict_tab TYPE TABLE OF pict_line, ? ?? url(255) TYPE c. DATA: graphic_url(255). DATA: BEGIN OF graphic_table OCCURS0, ? ?? ? line(255) TYPE x, ? ?? END OF graphic_table. DATA: l_graphic_conv TYPE i. DATA: l_graphic_offs TYPE i. DATA: graphic_size TYPE i. DATA: l_graphic_xstr TYPE xstring. .
"刷新 CALL METHOD cl_gui_cfw=>flush.
"創建容器 CREATE OBJECT:container EXPORTINGcontainer_name = 'GL_IMAGE', ? ?? ? ?? ? picture EXPORTING parent =container.
"獲取圖片 CALL METHODcl_ssf_xsf_utilities=>get_bds_graphic_as_bmp ? EXPORTING ? ?p_object ? ? ? ='GRAPHICS' ? ?p_name ? ? ?? = 'ZUS_LOGO' ? ? p_id? ? ?? ? = 'BMAP' ? ?p_btype ? ? ??= 'BCOL' ? RECEIVING ? ? p_bmp? ? ?? ?= l_graphic_xstr ? ?? ? .
"圖片大小 graphic_size = XSTRLEN( l_graphic_xstr). l_graphic_conv = graphic_size. l_graphic_offs = 0.
"將圖片數據放到內表中 WHILE l_graphic_conv > 255. ? graphic_table-line =l_graphic_xstr+l_graphic_offs(255). ? APPENDgraphic_table. ? l_graphic_offs =l_graphic_offs + 255. ? l_graphic_conv =l_graphic_conv - 255. ENDWHILE. graphic_table-line =l_graphic_xstr+l_graphic_offs(l_graphic_conv). APPEND graphic_table.
"創建圖片的URL CALL FUNCTION 'DP_CREATE_URL' ? EXPORTING ? ? type? ? = 'IMAGE' ? ?subtype ?= 'X-UNKNOWN' ? ? size? ? = graphic_size ? ?lifetime = 'T' ? TABLES ? ? data? ? = graphic_table ? CHANGING ? ? url? ? ?=url.
"根據URL 展示圖片 CALL METHODpicture->load_picture_from_url ? EXPORTING ? ? url =url.
"顯示模式 居中自適應 CALL METHODpicture->set_display_mode ? EXPORTING ? ?display_mode = picture->display_mode_fit_center.
在屏幕 9000上創建容器 ?GL_IMAGE?并處理相應的PAI和PBO事件,在PBO事件中增加一個MODULE,在其中添加如下代碼: DATA: w_lines TYPE i. TYPES pict_line(256) TYPE c. DATA : ? ?? container TYPE REF TOcl_gui_custom_container, ? ?? editor TYPE REF TO cl_gui_textedit, ? ?? picture TYPE REF TO cl_gui_picture, ? ?? pict_tab TYPE TABLE OF pict_line, ? ?? url(255) TYPE c. DATA: graphic_url(255). DATA: BEGIN OF graphic_table OCCURS0, ? ?? ? line(255) TYPE x, ? ?? END OF graphic_table. DATA: l_graphic_conv TYPE i. DATA: l_graphic_offs TYPE i. DATA: graphic_size TYPE i. DATA: l_graphic_xstr TYPE xstring. .
"刷新 CALL METHOD cl_gui_cfw=>flush.
"創建容器 CREATE OBJECT:container EXPORTINGcontainer_name = 'GL_IMAGE', ? ?? ? ?? ? picture EXPORTING parent =container.
"獲取圖片 CALL METHODcl_ssf_xsf_utilities=>get_bds_graphic_as_bmp ? EXPORTING ? ?p_object ? ? ? ='GRAPHICS' ? ?p_name ? ? ?? = 'ZUS_LOGO' ? ? p_id? ? ?? ? = 'BMAP' ? ?p_btype ? ? ??= 'BCOL' ? RECEIVING ? ? p_bmp? ? ?? ?= l_graphic_xstr ? ?? ? .
"圖片大小 graphic_size = XSTRLEN( l_graphic_xstr). l_graphic_conv = graphic_size. l_graphic_offs = 0.
"將圖片數據放到內表中 WHILE l_graphic_conv > 255. ? graphic_table-line =l_graphic_xstr+l_graphic_offs(255). ? APPENDgraphic_table. ? l_graphic_offs =l_graphic_offs + 255. ? l_graphic_conv =l_graphic_conv - 255. ENDWHILE. graphic_table-line =l_graphic_xstr+l_graphic_offs(l_graphic_conv). APPEND graphic_table.
"創建圖片的URL CALL FUNCTION 'DP_CREATE_URL' ? EXPORTING ? ? type? ? = 'IMAGE' ? ?subtype ?= 'X-UNKNOWN' ? ? size? ? = graphic_size ? ?lifetime = 'T' ? TABLES ? ? data? ? = graphic_table ? CHANGING ? ? url? ? ?=url.
"根據URL 展示圖片 CALL METHODpicture->load_picture_from_url ? EXPORTING ? ? url =url.
"顯示模式 居中自適應 CALL METHODpicture->set_display_mode ? EXPORTING ? ?display_mode = picture->display_mode_fit_center.
總結
- 上一篇: ABAP 如何判断调用smartform
- 下一篇: OO ALV 工具栏对于的功能码