SAP文件的上传

    xiaoxiao2023-03-25  6

    上传文件前,取得上传文件的名称 FORM help_dis_u. DATA: lc_lname TYPE string, lc_txt TYPE string, lc_txtfl TYPE string, lt_filet TYPE TABLE OF file_table, lw_filet LIKE LINE OF lt_filet, lc_rc TYPE i, lc_usera TYPE i. lc_lname = text-d01. "本地文件名 * IF P_EXCEL IS NOT INITIAL."EXCEL lc_txt = text-d02. "'*.xls' lc_txtfl = text-d03. "'MS EXCEL|*.xls;*xlsx|' * ELSE."TXT * LC_TXT = TEXT-D04. "'*.txt' * LC_TXTFL = TEXT-D05. "'MS TXT|*.txt|' * ENDIF. * 打开对话框 CALL METHOD cl_gui_frontend_services=>file_open_dialog EXPORTING window_title = lc_lname "本地文件名 default_extension = lc_txt "'*.xls' file_filter = lc_txtfl "'MS EXCEL|*.xls|' CHANGING file_table = lt_filet "文件名表 rc = lc_rc "文件数 user_action = lc_usera "用户命令 EXCEPTIONS file_open_dialog_failed = 1 cntl_error = 2 error_no_gui = 3 not_supported_by_gui = 4 OTHERS = 5. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. IF lc_usera = 0. READ TABLE lt_filet INTO lw_filet INDEX 1. p_fname = lw_filet-filename. ENDIF. ENDFORM. "HELP_DIS_U 上传数据文件前,需要对数据文件进行检验 DATA: lc_rc TYPE c, lc_file TYPE string, lc_path(100) TYPE c. flg_stop = space. lc_file = p_fname. IF p_fname = space. SET CURSOR FIELD cns_fname. * 文件路径不能为空。 MESSAGE e001. ENDIF. CALL METHOD cl_gui_frontend_services=>file_exist EXPORTING file = lc_file "文件类型 RECEIVING result = lc_rc "结果 EXCEPTIONS cntl_error = 1 error_no_gui = 2 wrong_parameter = 3 not_supported_by_gui = 4 OTHERS = 5. IF lc_rc = space. SET CURSOR FIELD cns_fname. *文件路径&1不存在。 MESSAGE e002 WITH lc_path. ENDIF. 对检测完成后数据文件进行上传 DATA it_upload LIKE TABLE OF alsmex_tabline. DATA wa_upload LIKE LINE OF it_upload. FORM get_data_upload. REFRESH it_upload. *--UPLOAD DATA FROM EXCEL TO INTERNAL TABLE CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE' EXPORTING filename = p_fname "文件路径 i_begin_col = 1 i_begin_row = 1 i_end_col = 21 i_end_row = 65536 TABLES intern = it_upload EXCEPTIONS inconsistent_parameters = 1 upload_ole = 2 OTHERS = 3. IF sy-subrc = 0. ENDIF. ENDFORM." UPLOAD_FROM_EXCEL
    转载请注明原文地址: https://ju.6miu.com/read-1203501.html
    最新回复(0)