*&---------------------------------------------------------------------* *& Report Z016 *& *&---------------------------------------------------------------------* *& *& 上传TXT文件 *&---------------------------------------------------------------------* REPORT Z016 MESSAGE-ID ZHQ NO STANDARD PAGE HEADING. TYPES:BEGIN OF MATERIAL, ID TYPE CHAR10, NAME TYPE CHAR50, END OF MATERIAL. DATA GT_MATERIAL TYPE TABLE OF MATERIAL WITH HEADER LINE. PARAMETERS P_FILE TYPE RLGRAP-FILENAME OBLIGATORY. AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE. CALL FUNCTION 'WS_FILENAME_GET' EXPORTING MASK = ',txt,*.txt,' MODE = 'O' TITLE = '我的物料' IMPORTING FILENAME = P_FILE EXCEPTIONS INV_WINSYS = 1 NO_BATCH = 2 SELECTION_CANCEL = 3 SELECTION_ERROR = 4 OTHERS = 5. START-OF-SELECTION. DATA TEMP_FILE TYPE STRING. TEMP_FILE = P_FILE. CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME = TEMP_FILE * FILETYPE = 'ASC' HAS_FIELD_SEPARATOR = 'X' * HEADER_LENGTH = 0 * READ_BY_LINE = 'X' * DAT_MODE = ' ' * CODEPAGE = ' ' * IGNORE_CERR = ABAP_TRUE * REPLACEMENT = '#' * CHECK_BOM = ' ' * VIRUS_SCAN_PROFILE = * NO_AUTH_CHECK = ' ' * IMPORTING * FILELENGTH = * HEADER = TABLES DATA_TAB = GT_MATERIAL * CHANGING * ISSCANPERFORMED = ' ' * EXCEPTIONS * FILE_OPEN_ERROR = 1 * FILE_READ_ERROR = 2 * NO_BATCH = 3 * GUI_REFUSE_FILETRANSFER = 4 * INVALID_TYPE = 5 * NO_AUTHORITY = 6 * UNKNOWN_ERROR = 7 * BAD_DATA_FORMAT = 8 * HEADER_NOT_ALLOWED = 9 * SEPARATOR_NOT_ALLOWED = 10 * HEADER_TOO_LONG = 11 * UNKNOWN_DP_ERROR = 12 * ACCESS_DENIED = 13 * DP_OUT_OF_MEMORY = 14 * DISK_FULL = 15 * DP_TIMEOUT = 16 * OTHERS = 17 . END-OF-SELECTION. DATA LEN TYPE I. DESCRIBE TABLE GT_MATERIAL LINES LEN. IF LEN > 0. LOOP AT GT_MATERIAL. WRITE : / GT_MATERIAL-ID,'---->',GT_MATERIAL-NAME. ENDLOOP. ELSE. DATA MESSAGE TYPE STRING. CONCATENATE P_FILE '-好像没有找到数据' INTO MESSAGE SEPARATED BY ''. MESSAGE S000 WITH MESSAGE DISPLAY LIKE 'E'. ENDIF.
标签:GT,DATA,GUI,MATERIAL,UPLOAD,FILE,ERROR,txt,TYPE From: https://www.cnblogs.com/hua900822/p/17381931.html