Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 01, 2009 at 08:12 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 01, 2009 at 07:28 AM

    check fm

    ADS2KIPUPL_GET_FILE_ATTRIBUTES

    or

    EPS_GET_FILE_ATTRIBUTES

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 01, 2009 at 07: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

    Add comment
    10|10000 characters needed characters exceeded

    • 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.