#Get mail attachment from SOST, and download to local#
ABAP发送出去的邮件,都会在Tcode SOST里可以看到,附件也可以在里面查看到,所以这边主要用到表SOOD去取发送出去的附件
原代码如下:
DATA lv_short_subject TYPE so_obj_des.
DATA ls_sood TYPE ty_sood.
DATA lv_obj_id TYPE sx_obj_id.
DATA ls_content TYPE sx_content.
DATA lt_binary_data TYPE solix_tab.
DATA lv_len TYPE i.
CALL FUNCTION 'SO_OBJECT_DATA_FOR_SEND_GET'
EXPORTING
object_id = lv_obj_id
IMPORTING
content = ls_content
EXCEPTIONS
err_obj_not_found = 1
err_no_authorization = 2
err_wrong_reference = 3
OTHERS = 4.
lt_binary_data = ls_content-linesx.
lv_len = ls_content-len.
DATA: filename TYPE string,
path TYPE string,
fullpath TYPE string.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
CHANGING
filename = filename
path = path
fullpath = fullpath
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_len
filename = fullpath
filetype = 'BIN'
TABLES
data_tab = lt_binary_data.