Hello, i wrote FM for reading files on application server, but it shows list of files in '/usr/sap/[server_name]/DVEBMGS01/work/' reagardless import directory parameter. What's wrong?
*"----------------------------------------------------------------------
*"*"
*" IMPORTING
*" REFERENCE(I_DIR) TYPE TEXT200
*" REFERENCE(I_FILE_MASK) TYPE TEXT100
*" TABLES
*" T_FILES TYPE ZT1TE0016_FILE
*" EXCEPTIONS
*" READ_FINISH_FAILED
*" READ_START_FAILED
*"----------------------------------------------------------------------
*
CONSTANTS c_generic_name(1) TYPE c VALUE '*'.
*
DATA:
l_sum_error TYPE i,
l_errno(3) TYPE c,
l_errmsg(40) TYPE c.
*
DATA g_timezone_sec(5) TYPE p. "seconds local time
*
DATA:
BEGIN OF file,
name(128) TYPE c, " name of entry. (possibly truncated.)
type(10) TYPE c, " type of entry.
len(8) TYPE p, " length in bytes.
owner(8) TYPE c, " owner of the entry.
mtime(6) TYPE p, " last modification date, seconds since 1970
mode(9) TYPE c, " like "rwx-r-x--x": protection mode.
mod_date TYPE d,
mod_time(8) TYPE c, " hh:mm:ss
END OF file.
*
DATA: ls_file_list TYPE zs1te0016_file,
lv_dir TYPE string.
lv_dir = i_dir.
PERFORM add_bs_to_folder USING lv_dir.
CALL 'C_DIR_READ_FINISH' "just to be sure "#EC CI_CCALL
ID 'ERRNO' FIELD l_errno
ID 'ERRMSG' FIELD l_errmsg.
IF sy-subrc <> 0 AND sy-subrc <> 3.
RAISE READ_FINISH_FAILED.
ENDIF.
CALL 'C_DIR_READ_START' ID 'DIR' FIELD lv_dir
ID 'FILE' FIELD i_file_mask
ID 'ERRNO' FIELD l_errno
ID 'ERRMSG' FIELD l_errmsg.
IF sy-subrc <> 0.
RAISE READ_START_FAILED.
ENDIF.
CLEAR l_sum_error.
* CLEAR gt_file_list.
* REFRESH gt_file_list.
DO.
CLEAR ls_file_list.
* IF l_sum_error > 10.
* MOVE text-m01 TO gw_file_list-name.
* APPEND gw_file_list TO gt_file_list.
* EXIT.
* ENDIF.
CLEAR file.
CALL 'C_DIR_READ_NEXT' "#EC CI_CCALL
ID 'TYPE' FIELD file-type
ID 'NAME' FIELD file-name
ID 'LEN' FIELD file-len
ID 'OWNER' FIELD file-owner
ID 'MTIME' FIELD file-mtime
ID 'MODE' FIELD file-mode
ID 'ERRNO' FIELD l_errno
ID 'ERRMSG' FIELD l_errmsg.
CASE sy-subrc.
WHEN 0. " or 4.
CLEAR: l_errno, l_errmsg.
CHECK file-name <> '.' AND file-name <> '..' .
CASE file-type(1).
WHEN 'F' or 'f'. " normal file.
MOVE 'F' TO ls_file_list-type.
WHEN 'D' or 'd'. " directory
MOVE 'D' TO ls_file_list-type.
WHEN OTHERS. " device, fifo, socket,...
MOVE 'S' TO ls_file_list-type.
ENDCASE.
PERFORM p6_to_date_time
USING file-mtime g_timezone_sec
file-mod_time
file-mod_date.
MOVE file-mode TO ls_file_list-mode.
MOVE file-owner TO ls_file_list-owner.
MOVE file-mod_date TO ls_file_list-date.
MOVE file-mod_time TO ls_file_list-time.
IF file-len > 9999999.
MOVE '>10 MB' TO ls_file_list-len.
ELSE.
WRITE file-len TO ls_file_list-len.
ENDIF.
MOVE file-name TO ls_file_list-name.
* CONCATENATE i_dir
* file-name
* INTO ls_file_list-full_name.
APPEND ls_file_list TO t_files.
WHEN 1. "End of List
EXIT. "exit do loop
WHEN OTHERS.
ADD 1 TO l_sum_error.
ENDCASE.
ENDDO.
CALL 'C_DIR_READ_FINISH' "#EC CI_CCALL
ID 'ERRNO' FIELD l_errno
ID 'ERRMSG' FIELD l_errmsg.
IF sy-subrc <> 0 AND sy-subrc <> 4.
RAISE READ_FINISH_FAILED.
ENDIF.
SORT t_files BY type ASCENDING name ASCENDING time DESCENDING.
ENDFUNCTION.