先通过 SE78 将图片导入到服务器.
本程序在SCREEN 9000中加入名为ZCONTAINER的 customer container.
DATA: container TYPE REF TO cl_gui_custom_container,
ok_code LIKE sy-ucomm,
save_ok LIKE ok_code.
DATA pic TYPE REF TO cl_gui_picture .
DATA result TYPE i.
DATA url(255).
DATA g_xstr TYPE xstring.
DATA g_size TYPE i.
DATA g_pos TYPE i.
DATA last_size TYPE i.
DATA loop_time TYPE i.
DATA: BEGIN OF g_tab OCCURS 0,
data(500) TYPE x,
END OF g_tab.
START-OF-SELECTION.
CALL METHOD cl_ssf_xsf_utilities=>get_bds_graphic_as_bmp
EXPORTING
p_object = 'GRAPHICS'
p_name = 'ZTEST'
p_id = 'BMAP'
p_btype = 'BCOL'
RECEIVING
p_bmp = g_xstr.
g_size = XSTRLEN( g_xstr ).
g_pos = 0.
loop_time = g_size DIV 500.
DO loop_time TIMES.
g_tab-data = g_xstr+g_pos(500).
APPEND g_tab.
g_pos = g_pos + 500.
ENDDO.
last_size = g_size - g_pos .
g_tab-data = g_xstr+g_pos(last_size).
APPEND g_tab.
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'IMAGE'
subtype = cndp_sap_tab_unknown
* SIZE = g_size
* DATE =
* TIME =
* description =
LIFETIME = cndp_lifetime_transaction
* CACHEABLE =
* SEND_DATA_AS_STRING =
* FIELDS_FROM_APP =
TABLES
data = g_tab
CHANGING
url = url
.
CREATE OBJECT container
EXPORTING
container_name = 'ZCONTAINER'
.
CREATE OBJECT pic
EXPORTING
parent = container
.
CALL METHOD pic->load_picture_from_url
EXPORTING
url = url
IMPORTING
RESULT = RESULT.
.
**** 设置显示模式.
**** mode 可取值:
**** 0:原始大小显示 1:图片自动调整大小显示 2:纵向拉伸,局左显示 3: 原始大小,居中显示
**** 4:纵向拉伸,居中显示
**** load的时候默认的是原始大小.
CALL METHOD pic->set_display_mode
EXPORTING
display_mode = 0
.
CALL SCREEN 9000.
阅读(10465) | 评论(8) | 转发(0) |