Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to find the size of file which is in application server...

Former Member
0 Kudos

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

1 ACCEPTED SOLUTION

venkat_o
Active Contributor
0 Kudos

Hi Puneet, Try this way.


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.
Thanks Venkat.O

7 REPLIES 7

kesavadas_thekkillath
Active Contributor
0 Kudos

check fm

ADS2KIPUPL_GET_FILE_ATTRIBUTES

or

EPS_GET_FILE_ATTRIBUTES

Former Member
0 Kudos

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

0 Kudos

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

0 Kudos

but suhas i want to full size of the file. how to find ?

0 Kudos

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

0 Kudos

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.

venkat_o
Active Contributor
0 Kudos

Hi Puneet, Try this way.


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.
Thanks Venkat.O