"자기 자신의 로컬 디렉토리 찾기(CV03 다운시)
DATA: LF_TMP_DIR TYPE STRING.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_TEMP_DIRECTORY
CHANGING: TEMP_DIR = LF_TMP_DIR
EXCEPTIONS: CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
ENDIF.
CALL METHOD CL_GUI_CFW=>FLUSH.
IF LF_TMP_DIR IS INITIAL.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GET_SAPGUI_DIRECTORY
CHANGING: SAPGUI_DIRECTORY = LF_TMP_DIR
EXCEPTIONS: CNTL_ERROR = 1
NOT_SUPPORTED_BY_GUI = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
ENDIF.
CALL METHOD CL_GUI_CFW=>FLUSH.
ENDIF.
"로컬 디렉토리의 파일 리스트 검색
DATA: L_FILETAB LIKE FILE_TABLE OCCURS 0 WITH HEADER LINE .
DATA: L_COUNT TYPE I.
DATA: DIR TYPE STRING.
DIR = LF_TMP_DIR.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>DIRECTORY_LIST_FILES
EXPORTING
DIRECTORY = DIR
* FILTER = '*.JPG'
* FILES_ONLY = 'X'
* DIRECTORIES_ONLY = 'X'
CHANGING
FILE_TABLE = L_FILETAB[]
COUNT = L_COUNT
EXCEPTIONS
CNTL_ERROR = 1
DIRECTORY_LIST_FILES_FAILED = 2
WRONG_PARAMETER = 3
ERROR_NO_GUI = 4
NOT_SUPPORTED_BY_GUI = 5
OTHERS = 6.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
"로컬 디렉토리의 파일 리스트 삭제 처리
LOOP AT L_FILETAB.
DATA: FILE_PATH TYPE STRING,
RET_VAR TYPE I.
FILE_PATH = L_FILETAB-FILENAME.
CONCATENATE DIR '' L_FILETAB-FILENAME INTO FILE_PATH.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_DELETE
EXPORTING
FILENAME = FILE_PATH
CHANGING
RC = RET_VAR
EXCEPTIONS
FILE_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
FILE_NOT_FOUND = 4
ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
OTHERS = 9.
ENDLOOP.
IF SY-SUBRC = 0.
ENDIF.
*로컬 PC에서 폴더 생성(이미 존재하는 폴더인지 확인후 존재할 경우 삭제후 생성)
<style type="text/css">
SPAN {
font-family: "Fixedsys";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S32 {
color: #3399FF;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}
</style>
DATA: LV_EXIST TYPE C.
*---function module to exist folder on presentation server
CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'
EXPORTING
FNAME = 'C:AAA'
IMPORTING
EXIST = LV_EXIST
EXCEPTIONS
FILEINFO_ERROR = 1
OTHERS = 2.
CHECK SY-SUBRC = 0.
IF LV_EXIST IS NOT INITIAL.
*---function module to delete folder on presentaion server
CALL FUNCTION 'TMP_GUI_REMOVE_DIRECTORY'
EXPORTING
DIRNAME = 'C:AAA'
EXCEPTIONS
FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDIF.
CHECK SY-SUBRC = 0.
*---function module to create folder on presentation server
CALL FUNCTION 'TMP_GUI_CREATE_DIRECTORY'
EXPORTING
DIRNAME = 'C:AAA'
NO_FLUSH = ' '
EXCEPTIONS
FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
좋은팁 공유 감사합니다.