Application Development and Automation 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: 
Read only

Issue in method file_get_size

Former Member
0 Likes
1,366

I am using the method "file_get_size" to identify the size of the file. Though the file contains details its returning the value as -1. It doesnt show the correct size. Could you please let me know the reason for it and how to correct it? The code is given below

data: filesize type i.

CLASS cl_gui_frontend_services DEFINITION LOAD.

call method cl_gui_frontend_services=>file_get_size

exporting

file_name = "File name"

importing

file_size = filesize

exceptions

others = 1.

call method cl_gui_cfw=>flush.

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,207

Hi ,

Just check the signature of the method FILE_GET_SIZE

FILE_SIZE TYPE I File Size, -1 if an Error Occurred.

I am using the method "file_get_size" to identify the size of the file. Though the file contains details its returning the value as -1. It doesnt show the correct size. Could you please let me know the reason for it and how to correct it? The code is given below

data: filesize type i.

CLASS cl_gui_frontend_services DEFINITION LOAD.

call method cl_gui_frontend_services=>file_get_size

exporting

file_name = "File name"

importing

file_size = filesize

exceptions

others = 1.

call method cl_gui_cfw=>flush.

7 REPLIES 7
Read only

guillaume-hrc
Active Contributor
0 Likes
1,207

Hi,

You mapped all errors to OTHERS with sysubrc = 1.

Try using the whole lot of exceptions to better identify the problem

  EXCEPTIONS
    file_get_size_failed = 1
    cntl_error           = 2
    error_no_gui         = 3
    not_supported_by_gui = 4
    others

Best regards,

Guillaume

Read only

0 Likes
1,207

Hi,

I used the exceptions specified by you. Actually am getting the value as "-1". what does it specifies?

Read only

Former Member
0 Likes
1,207

Your file is named "File name"? No path?

And i bet an exception was raised...

-


Please hug me!

Read only

0 Likes
1,206

I have specified the path name

Read only

0 Likes
1,206

With single quotes or double quotes?

-


Please hug me!

Read only

0 Likes
1,206

And while you're at it: check the contents of SY-MSGNO and so on.

-


Please hug me!

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
1,208

Hi ,

Just check the signature of the method FILE_GET_SIZE

FILE_SIZE TYPE I File Size, -1 if an Error Occurred.