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: 

Reg: FILE_GET_SIZE

Former Member
0 Kudos

Hi Group,

I want to know the size of the excel file which i am uploading to the internal table.

i am using the method file_get_size.

CALL METHOD cl_gui_frontend_services=>file_get_size

EXPORTING

file_name = gv_file

IMPORTING

file_size = gv_filesize.

the problem is for the first time the filesize is 0 the actual size is not displaying in the filesize.

What is the problem here????

thanks in advance

Regards,

Suganya.

9 REPLIES 9

Former Member
0 Kudos

can you paste your whole code?

Regards,

Atish

former_member223537
Active Contributor
0 Kudos

Hi,

If you are uploading the file using FM 'GUI_UPLOAD', then the FM itself has a parameter "FILELENGTH", which will provide you the file size which is uploaded.

Best regards,

Prashant

Former Member
0 Kudos

Hi,

In my requirement, i want to uplaod a file into the internal. if the file is empty error message should be displayed. My code is given below:

SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-004.

PARAMETERS: p_fname LIKE rlgrap-filename OBLIGATORY.

SELECTION-SCREEN END OF BLOCK blk1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.

  • Search help for P_FNAME parameter.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = gv_cprog

dynpro_number = gv_dynnr

IMPORTING

file_name = p_fname.

AT SELECTION-SCREEN ON p_fname.

  • Check whether the given file name exists or not

gv_file = p_fname.

gv_fileexists = cl_gui_frontend_services=>file_exist( gv_file ).

IF gv_fileexists IS INITIAL.

MESSAGE e002(zmsg_ss). " file does not exist

ENDIF.

CALL METHOD cl_gui_frontend_services=>file_get_size

EXPORTING

file_name = gv_file

IMPORTING

file_size = gv_filesize.

IF gv_filesize EQ 0.

MESSAGE e003(zmsg_ss). " file is empty

ENDIF.

Regards,

Suganya.

0 Kudos

Hi,

Can you move code from AT SELECT..

To START-OF_SE..

Regards,

Atish

Former Member
0 Kudos

Hi,

Same problem is coming again..

i guess the problem is with the method. the file_size is empty for the first excution and for the second excution the file size is 16000 but my actual file size is 600.

regards,

Suganya.

former_member223537
Active Contributor
0 Kudos

The file should be closed, during execution of program & data type of gv_size should be i.

data : Gv_size type i.

Former Member
0 Kudos

Hi,

I have already declared the file size as i.

Data: gv_filesize type i.

Regards,

Suganya.

0 Kudos

hi,

try to insert line after calling method file_size:

<b>CALL METHOD cl_gui_cfw=>flush.</b>

Message was edited by:

Andreas Mann

0 Kudos

Excellent Andreas.. Cheers... It's solve my problem too...

Thanks

Gourab