-
文件上传
DATA: lv_class TYPE toadv-doc_type, lv_objectid TYPE sapb-sapobjid. CALL FUNCTION 'ZARCHIV_CREATE_DIALOG_META' EXPORTING archiv_id = 'Z1' "内容存储库ID ar_object = 'ZALLFILES' "文档类型
-
DEL_DATE = ' '
-
NOTE = ' ' object_id = lv_objectid "对象标识 sap_object = 'BUS1001' "T_ZTFILE001-SAP_OBJECT "对象类型
-
FILE = pv_path document_class = lv_class "文档类,后缀名
-
COMMIT_FLAG = ' '
-
VSCAN_PROFILE = '/SCMS/KPRO_CREATE'
-
FILE_DESCR_POP_SUP = ' ' IMPORTING archiv = lv_archiv_id "内容存储库ID archiv_doc_id = lv_archiv_doc_id "文档ID documentclass = lv_documentclass "文档类
-
TABLES
-
OUTDOCTAB = CHANGING infiletab = lt_file EXCEPTIONS error_archiv = 1 error_communicationtable = 2 error_connectiontable = 3 error_kernel = 4 error_parameter = 5 error_scanqueue = 6 canceled_by_user = 7 blocked_by_policy = 8 OTHERS = 9. IF sy-subrc <> 0. IF sy-subrc = 1. MESSAGE '选择的文件不存在'(029) TYPE 'S' DISPLAY LIKE 'E'. ELSE. MESSAGE '上传失败,请重新上传文件'(030) TYPE 'S' DISPLAY LIKE 'E'. ENDIF. ENDIF.
-
-
文件下载
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
default_extension = lv_doc_type1 "默认保存文件格式
default_file_name = lv_filename "默认文件名称
CHANGING
filename = lc_filename "默认文件名称
path = lc_path "文件路径
fullpath = lc_fullpath "文件路径
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE'
EXPORTING
archiv_id = 'Z1'
document_type = lv_doc_type
archiv_doc_id = gs_matnritem-zfileguid
IMPORTING
binlength = lv_lenth
TABLES
binarchivobject = lt_bin.
lv_input_length = lv_lenth.
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_input_length
IMPORTING
buffer = lv_file
TABLES
binary_tab = lt_bin
EXCEPTIONS
failed = 1
OTHERS = 2.cl_gui_frontend_services=>gui_download( EXPORTING filename = iv_filename filetype = 'BIN' bin_filesize = xstrlen( lv_file ) CHANGING data_tab = lt_data[] EXCEPTIONS OTHERS = 1 ). IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 RAISING download_error. ENDIF.
-
获取文件URL
CALL FUNCTION 'SCMS_AO_URL_READ'
EXPORTING
arc_id = archiv_id
doc_id = archiv_doc_id
comp_id = ' '
document_type = document_class
loc_info = 'F'
http_url_only = 'X'
IMPORTING
url = absolute_uri
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 RAISING others .
ENDIF.
ARCHIVOBJECT_GET_URI
生成URL的时候 SCMS_URL_GENERATE会调用SCMS_URL_SIGN函数这是其中默认这是了URL的生效时间为两小时
如果需要失效时间延长会设置URL永久有效, 可以去修改函数SCMS_URL_GENERATE的参数DURATION 或EXPIRATION ,DURATION最大时间是999999,若需要永久有效,则需要设置EXPIRATION的时间,这时系统会忽略DURATION的参数,