GUI Upload 실 사용 로직입니다.
도움이 됐으면 합니다.
- 구성은 선언부
- Upload form문
- 실 GUI Upload Function 실행해서 읽어 들이기 입니다.
1. data 선언
* UPLOAD FORMAT INTERNAL TABLE DATA: BEGIN OF GT_UP OCCURS 0, . . . . . . END OF GT_UP. DATA: GV_ERROR . PARAMETERS: P_FILE LIKE RLGRAP-FILENAME OBLIGATORY DEFAULT 'C:*.XLS'. |
2. Upload Form문
FORM FILE_UPLOAD . DATA : LV_PATH(255), LV_PATH2(255), LV_FILE(255), LV_FILE2(255). CLEAR: LV_PATH, LV_PATH2, LV_FILE, LV_FILE2, GV_ERROR, GT_UP, GT_UP[]. *. 엑셀파일인지 확인작업 MOVE P_FILE TO LV_FILE . DO. SPLIT LV_FILE AT '.' INTO LV_PATH LV_FILE . TRANSLATE LV_FILE TO UPPER CASE. IF LV_FILE = 'XLS' OR LV_FILE = SPACE. EXIT . ENDIF. ENDDO. CASE LV_FILE . WHEN 'XLS' . WHEN OTHERS . MESSAGE S000 WITH 'Upload 할 수 없는 파일형태입니다' . GV_ERROR = 'X' . STOP . ENDCASE . PERFORM EXCEL_FILE_UPLOAD TABLES GT_UP USING P_FILE. |
3. GUI-UPLOAD 실행
FORM EXCEL_FILE_UPLOAD TABLES PT_UP USING PV_FNAME . * DATA: LV_FILENAME TYPE STRING, LV_FILENAME2 LIKE RLGRAP-FILENAME, LT_RAW_DATA TYPE TRUXS_T_TEXT_DATA. DATA: LV_TOTAL TYPE I. * CLEAR: LV_TOTAL. * LV_FILENAME = PV_FNAME. * CALL FUNCTION 'GUI_UPLOAD' EXPORTING FILENAME = LV_FILENAME FILETYPE = 'ASC' HAS_FIELD_SEPARATOR = '#' TABLES DATA_TAB = LT_RAW_DATA 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. * IF SY-SUBRC = 0. LV_FILENAME2 = LV_FILENAME. CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP' EXPORTING I_FIELD_SEPERATOR = '#' I_TAB_RAW_DATA = LT_RAW_DATA I_FILENAME = LV_FILENAME2 TABLES I_TAB_CONVERTED_DATA = PT_UP. ENDIF. * DELETE PT_UP FROM 1 TO 1. * DESCRIBE TABLE PT_UP LINES LV_TOTAL. * IF LV_TOTAL = 0. GV_ERROR = 'X' . MESSAGE I000 WITH 'Upload Data가 없습니다!!'. STOP. ENDIF. * ENDFORM. "WS_UPLOAD |
감사합니다 제가 원하던거네요.