输入的内表动态确定,可以修改
代码如下
FUNCTION ZFM_TEST_FILE. *"---------------------------------------------------------------------- *"*"本地接口: *" TABLES *" TAB *"---------------------------------------------------------------------- DATA : CL_TAB TYPE REF TO CL_ABAP_STRUCTDESCR, LT_FILE TYPE STANDARD TABLE OF STRING, WA_EILE LIKE LINE OF LT_FILE. FIELD-SYMBOLS : <FS_TAB> TYPE STANDARD TABLE, <FS_WAB> TYPE ANY, <FS_INT> TYPE ABAP_COMPDESCR, <FS_VAL> . LOOP AT TAB ASSIGNING <FS_WAB>. CL_TAB ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( <FS_WAB> ). LOOP AT CL_TAB->COMPONENTS ASSIGNING <FS_INT>. ASSIGN COMPONENT <FS_INT>-NAME OF STRUCTURE <FS_WAB> TO <FS_VAL>. IF SY-SUBRC = 0. IF WA_EILE IS NOT INITIAL. CONCATENATE WA_EILE <FS_VAL> INTO WA_EILE SEPARATED BY '|'. ELSE. WA_EILE = <FS_VAL> . ENDIF. ELSE. ENDIF. ENDLOOP. APPEND WA_EILE TO LT_FILE . CLEAR WA_EILE . ENDLOOP. DATA PATH TYPE string VALUE 'C:UsersjaxDesktop下载的文件'. path = path && '.TXT' . CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD EXPORTING FILENAME = PATH * FILETYPE = 'PDF' CODEPAGE = '4103' " '8400' * filetype = 'BIN' * FILETYPE = 'BIN' WRITE_BOM = 'X' * WRITE_LF = 'X' CHANGING DATA_TAB = LT_FILE EXCEPTIONS FILE_WRITE_ERROR = 1 NO_BATCH = 2 GUI_REFUSE_FILETRANSFER = 3 INVALID_TYPE = 4 NO_AUTHORITY = 5 UNKNOWN_ERROR = 6 HEADER_NOT_ALLOWED = 7 SEPARATOR_NOT_ALLOWED = 8 FILESIZE_NOT_ALLOWED = 9 HEADER_TOO_LONG = 10 DP_ERROR_CREATE = 11 DP_ERROR_SEND = 12 DP_ERROR_WRITE = 13 UNKNOWN_DP_ERROR = 14 ACCESS_DENIED = 15 DP_OUT_OF_MEMORY = 16 DISK_FULL = 17 DP_TIMEOUT = 18 FILE_NOT_FOUND = 19 DATAPROVIDER_EXCEPTION = 20 CONTROL_FLUSH_ERROR = 21 NOT_SUPPORTED_BY_GUI = 22 ERROR_NO_GUI = 23 OTHERS = 24. ENDFUNCTION.
效果如图