**** 删除簇,用 DELETE FROM DATABASE indx(ZZ) ID 'PIC'.
值得注意的是:
load_picture_from_url 的result参数
在这个方法调用完的时候, 这个result参数并不会马上起作用,这里只是把这个result参数传给cl_gui_picture的对象而已.因为load只是对象简单的把数据和自己联系起来,但是还不知道这些数据到底能否组成一张图片.而要等到PBO之后,也就是图片显示出来了之后,该对象才知道. 它才会把之前传给load_picture_from_url 方法的那个参数result变成1或者0,也就是我们只有在PAI里才可以取得到这个值......
**** 在导入到 INDX 之前,要先用SELECT语句看是不是已经有这条记录了。 因为如果已经存在了**** 该条记录,再导入的话,会覆盖掉以前的那条。
DATA: BEGIN OF pic_tab OCCURS 0,
my_data(500) TYPE x,
END OF pic_tab.
DATA: container TYPE REF TO cl_gui_custom_container,
pic TYPE REF TO cl_gui_picture,
url(256),
resu TYPE i VALUE 123,
path_string TYPE string,
ok_code LIKE sy-ucomm,
save_ok LIKE ok_code,
wa_indx LIKE indx,
temp_char(2).
PARAMETERS f_path LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR f_path.
CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
static = 'X'
CHANGING
file_name = f_path.
START-OF-SELECTION.
DATA my_data TYPE REF TO cl_gui_cfw.
path_string = f_path.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = path_string
filetype = 'BIN'
TABLES
data_tab = pic_tab[].
CALL FUNCTION 'DP_CREATE_URL'
EXPORTING
type = 'IMAGE'
subtype = cndp_sap_tab_unknown
TABLES
data = pic_tab[]
CHANGING
url = url.
CREATE OBJECT container
EXPORTING
container_name = 'ZC'
.
CREATE OBJECT pic
EXPORTING
parent = container
.
CALL METHOD pic->load_picture_from_url
EXPORTING
url = url
IMPORTING
RESULT = resu.
CALL SCREEN 9000.
*&---------------------------------------------------------------------*
*& Form to_database
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM to_database.
IF resu = 1.
wa_indx-aedat = sy-datum.
wa_indx-usera = 'Li Hai Xin'.
SELECT SINGLE relid FROM indx INTO temp_char
WHERE relid = 'ZZ' AND srtfd = 'MY_PIC2'.
IF sy-subrc = 0.
MESSAGE i000(o0) WITH 'This id in region ''ZZ'' is exists'.
ELSE.
EXPORT pic_tab[] TO DATABASE indx(zz) ID 'MY_PIC1' FROM wa_indx.
MESSAGE i000(o0) WITH 'Successful'.
ENDIF.
ELSEIF resu = 0.
MESSAGE e000(o0) WITH 'If the picture can''t display, you can''t import it to database'.
ENDIF.
ENDFORM. "to_database
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_9000 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_9000 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'INPUT'.
PERFORM to_database.
ENDCASE.
ENDMODULE. " USER_COMMAND_9000 INPUT
阅读(1090) | 评论(0) | 转发(0) |