‎2006 Aug 04 8:04 AM
Hello All,
I have a requirement to get the files from shared folder(may be application server), is there any specific function module to get the list of files.
Dilip
‎2006 Aug 04 8:09 AM
to read file from application server,
USE
OPEN DATASET <FILENAME> FOR INPUT IN TEXT MODE ENCODING DEFAULT.
to read the contents of the file,
USE
READ DATASET <FILENAME> INTO V_STRING.
v_string will have the contents (1 line only)
and finally to close the file,
USE
CLOSE DATASET <FILENAME>
regards
srikanth
‎2006 Aug 04 8:13 AM
total logic to get total contents of the file into the program.
data : begin of itab occurs 0,
LINE TYPE STRING,
end of itab.
OPEN DATASET <FILENAME> FOR INPUT IN TEXT MODE ENCODING DEFAULT.
DO.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
READ DATASET <FILENAME> INTO V_STRING.
IF V_STRING IS NOT INITIAL.
ITAB-LINE = V_STRING.
APPEND ITAB.
ENDIF.
ENDDO.
CLOSE DATASET <FILENAME>.
if you use this logic, the contents of the file will be comes into the internal table ITAB.
but <FILENAME> should be given total path. not the just filename.you should give the absolute path name along with file name.
regards
srikanth
‎2006 Aug 04 8:13 AM
Hi Srikanth,
The filename can be any so first I have to get it the list of files.
Dilip
‎2006 Aug 04 8:15 AM
Hi,
Copy paste this code. you'll get all the files from your dir.
data: begin of tabl occurs 500,
line(400),
end of tabl.
data: unixcom like rlgrap-filename.
data: lines type i.
unixcom = 'ls -al'.
refresh tabl.
call 'SYSTEM' id 'COMMAND' field unixcom
id 'TAB' field tabl[].
describe table tabl lines lines.
loop at tabl.
write:/01 tabl-line.
endloop.
skip 2.
if lines = 0.
write:/ 'NO Occurances were found'.
endif.
Regards,
Sumit.
‎2006 Aug 04 8:31 AM
Hi,
This program allows the user to choose a file on application server and downloads the same to an Internal table.
REPORT zes_sample.
DATA : filename LIKE dxfields-longpath.
DATA : BEGIN OF it_test OCCURS 0,
a(200) TYPE c,
END OF it_test.
*------------------------------------------
CALL FUNCTION 'F4_DXFILENAME_TOPRECURSION'
EXPORTING
i_location_flag = 'A'
* I_SERVER = '?'
* I_PATH =
* FILEMASK = '*.*'
* FILEOPERATION = 'R'
IMPORTING
* O_LOCATION_FLAG =
* O_SERVER =
o_path = filename
* ABEND_FLAG =
EXCEPTIONS
rfc_error = 1
error_with_gui = 2
OTHERS = 3.
BREAK-POINT.
OPEN DATASET filename FOR INPUT IN BINARY MODE.
WHILE sy-subrc = 0.
CLEAR it_test .
READ DATASET filename INTO it_test.
APPEND it_test.
ENDWHILE.
<b>AS</b>
‎2006 Aug 04 1:25 PM