ABAP 上传 下载

GUI_UPLOAD/WS_UPLOAD: 上传文档
GUI_DOWNLOAD/WS_DOWNLOAD:下载文档
GUI_UPLOAD和GUI_DOWNLOAD是类CL_GUI_FRONTEND_SERVICES的静态方法.SAP在静态方法中直接使用了FUNCTION---GUI_UPLOAD和GUI_DOWNLOAD。
WS_UPLOAD和WS_DOWNLOAD属于被淘汰的FUNCTION,不建议使用。
上传下载TXT文档:GUI_UPLOAD/GUI_DOWNLOAD
上传下载EXCEL文档:TEXT_CONVERT_XLS_TO_SAP/SAP_CONVERT_TO_XLS_FORMAT
1.打开选择路径

 CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
   EXPORTING
     WINDOW_TITLE     = 'Select File'
     DEFAULT_FILENAME = '*.*'
     MULTISELECTION   = ' '
   CHANGING
     FILE_TABLE       = ITAB
     RC               = GD_SUBRC.
  1. 上传EXCEL
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
    EXPORTING
      I_LINE_HEADER        = 'X'
      I_TAB_RAW_DATA       = IT_RAW      " WORK TABLE
      I_FILENAME           = IN_FILE
    TABLES
      I_TAB_CONVERTED_DATA = ITAB_C[]   "ACTUAL DATA
    EXCEPTIONS
      CONVERSION_FAILED    = 1
      OTHERS               = 2.

3.上传TXT.(建议使用GUI_UPLOAD)

CALL FUNCTION 'WS_UPLOAD'
    EXPORTING
      FILENAME                = IN_FILE
      FILETYPE                = 'DAT'
    TABLES
      DATA_TAB                = ITAB_C
    EXCEPTIONS
      CONVERSION_ERROR        = 1
      INVALID_TABLE_WIDTH     = 2
      INVALID_TYPE            = 3
      NO_BATCH                = 4
      UNKNOWN_ERROR           = 5
      GUI_REFUSE_FILETRANSFER = 6
      OTHERS                  = 7.

你可能感兴趣的:(ABAP 上传 下载)