10-01-2009 8:24 AM
Hi team
i want to find the size of the file which is in application server?
is there any FM to find the size of the file?
Example:-->
p_file = '\tmp\source.txt'.
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
?----find the size of the file which is open ?
Thanks in Advance.
Regards.
Puneet
10-01-2009 9:12 AM
Hi Puneet,
Try this way.
Thanks
Venkat.O
REPORT ztest_program.
DATA filesize TYPE epsf-epsfilsiz.
CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
EXPORTING
file_name = 'llbdbase.dat'
dir_name = '/tmp/'
IMPORTING
file_size = filesize.
WRITE: 'File size' , filesize.
10-01-2009 8:28 AM
10-01-2009 8:33 AM
Hi,
Declare a integer variable and find the size.
data: var type string,
len type i.
p_file = '\tmp\source.txt'.
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
if sy-subrc = 0.
read dataset p_file into var.
endif.
describe field var length len in byte mode
write: 'The file size is', len.
Regards,
Vikranth
10-01-2009 8:45 AM
What??
Please note READ DATASET will read only one file pointer (in layman's term only one file line) at a time.
So your logic wont give the complete file size, will it?
BR,
Suhas
10-01-2009 8:49 AM
10-01-2009 8:55 AM
Hello,
As suggested by Keshu, you can use the FM: EPS_GET_FILE_ATTRIBUTES.
You get file size from the EXPORT param FILE_SIZE.
BR,
Suhas
10-01-2009 9:10 AM
When open dataset is used in BINARY MODE, the read dataset statement transfers the whole file content into the variable and not just one line as in TEXT MODE.
data: var type string,
len type i.
p_file = '\tmp\source.txt'.
OPEN DATASET p_file FOR INPUT IN BINARY MODE.
if sy-subrc = 0.
read dataset p_file into var.
endif.
describe field var length len in byte mode
write: 'The file size is', len.
So this will work and return the total size.
10-01-2009 9:12 AM
Hi Puneet,
Try this way.
Thanks
Venkat.O
REPORT ztest_program.
DATA filesize TYPE epsf-epsfilsiz.
CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
EXPORTING
file_name = 'llbdbase.dat'
dir_name = '/tmp/'
IMPORTING
file_size = filesize.
WRITE: 'File size' , filesize.