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

METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST

Former Member
0 Likes
2,253

Hi,

In METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST

EXPORTING

FILE =

RECEIVING

RESULT = . <-- May I know what is this result stand for and what kind of parameter should I pass in? Thanks!

Anyi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,655

Result is of type ABAP_BOOL which is TYPE C length 1. It takes two values, space and 'X'.

Hi,

In METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST

EXPORTING

FILE =

RECEIVING

RESULT = . <-- May I know what is this result stand for and what kind of parameter should I pass in? Thanks!

Anyi

7 REPLIES 7
Read only

Former Member
0 Likes
1,655

HI ANYI,

RESULT:IS THE RETURN CODE FOR THE BUTTON U HAVE CLICKED

FOR EX: '1' MIGHT BE THE RETURN CODE FOR 'YES'.

DECLARE RESULT AS

DATA: V_RES TYPE i.

METHOD CL_GUI_FRONTEND_SERVICES=>FILE_EXIST

EXPORTING

FILE =

RECEIVING

RESULT = V_RES.

Message was edited by: Priya

Read only

0 Likes
1,655

So in this case, the file in exporting is the name of the file to be checked, is that correct?

Thanks,

Anyi

Read only

0 Likes
1,655

hi Zhu,

Check this out

data: file_name type string.

data: <b>result type abap_bool.</b>

data: rc type i.

file_name = txt_work_file.

call method cl_gui_frontend_services=>file_exist

exporting

file = file_name

receiving

result = result

exceptions

cntl_error = 1

error_no_gui = 2

wrong_parameter = 3

others = 4.

Read only

Former Member
0 Likes
1,655

This is a RECEIVING parameter. You do not enter anything. SAP will fill this field for you. It is the confirmation of whether or not the file exists in the specific path provided in your FILE parameter.

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,655

This is a RECIEVING parameter, and you can use a TYPE ABAP_BOOL variable here. It will be "X" if the file exists, blank if not.




type-pools: abap.

data: result type abap_bool.
data: filename type string.


filename = 'C:test.xls'.


call method cl_gui_frontend_services=>file_exist
  exporting
      file =  filename
  receiving
     result = result .

if result = 'X'.
  write:/ 'Yep, file is there'.
else.
  write:/ 'Nop, file isnt there'.
endif.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,656

Result is of type ABAP_BOOL which is TYPE C length 1. It takes two values, space and 'X'.

Read only

0 Likes
1,655

Correct