v41dugu 发表时间:2008-03-27 09:06:53 |
|
老白你好 . 把图片存到数据库中应该怎样实现? 数据库中的图片是以二进制存在的? 那么和用SE78把图片导入到server上有什么不同呢?
|
*&---------------------------------------------------------------------*
*& Report Z_BARRY_CLUSTER_PIC *
*& *
*&---------------------------------------------------------------------*
*& 把图片放到簇表,然后取出显示 *
*& *
*&---------------------------------------------------------------------*
REPORT z_barry_cluster_pic .
DATA container TYPE REF TO cl_gui_custom_container.
DATA picture TYPE REF TO cl_gui_picture.
DATA ok_code TYPE sy-ucomm.
DATA subrc TYPE i.
SET SCREEN 100.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
SET PF-STATUS 'STATUS'.
PERFORM fill_pic.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module exit INPUT
*&---------------------------------------------------------------------*
MODULE exit INPUT.
CALL METHOD picture->free.
CALL METHOD container->free.
LEAVE PROGRAM.
ENDMODULE. " exit INPUT
*&---------------------------------------------------------------------*
*& Form fill_pic
*&---------------------------------------------------------------------*
FORM fill_pic .
DATA: url(255) .
IF container IS INITIAL.
CREATE OBJECT container
EXPORTING container_name = 'CUSTOM_CONTAINER'.
CREATE OBJECT picture
EXPORTING parent = container.
CLEAR url.
PERFORM load_pic_from_db CHANGING url.
CALL METHOD picture->load_picture_from_url
EXPORTING
url = url
IMPORTING
RESULT = subrc
EXCEPTIONS
error = 1
OTHERS = 2.
ENDIF.
ENDFORM. " fill_pic
*&---------------------------------------------------------------------*
*& Form LOAD_PIC_FROM_DB
*&---------------------------------------------------------------------*
FORM load_pic_from_db CHANGING url.
TYPES pict_line(256) TYPE x.
DATA itab_pic TYPE TABLE OF pict_line WITH HEADER LINE .
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'C:\20.jpg'
filetype = 'BIN'
TABLES
data_tab = itab_pic[].
EXPORT itab_pic TO DATABASE indx(zz) ID 'Pic' .
REFRESH itab_pic.
IMPORT itab_pic FROM DATABASE indx(zz) ID 'Pic' .
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'IMAGE'
subtype = 'GIF'
TABLES
data = itab_pic[]
CHANGING
url = url.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
ENDFORM. "load_pic_from_db
阅读(4794) | 评论(7) | 转发(0) |