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

function modul for file

Former Member
0 Likes
845

hi all.

if i want get a boolean value that explain if there is a file in a server directory, can i use a particular function?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
811

This message was moderated.

7 REPLIES 7
Read only

vinod_vemuru2
Active Contributor
0 Likes
811

Hi,

If it is in the presentation server, Check out the class CL_GUI_FRONTEND_SERVICES. There is a method for checking the existence of the file.

Read only

0 Likes
811

in my system there isn't this fm

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
811

If its presentation server use cl_gui_frontend_services=>file_exist

if application server then use DX_FILE_EXISTENCE_CHECK or just use a open dataset statement and check the value of sy-subrc.

Read only

0 Likes
811

fm DX_FILE_EXISTENCE_CHECK how can i use it?

Read only

0 Likes
811

This function module can be used for both servers.



parameters:  p_file(128) .

at selection-screen on p_file.
  perform check_file_exist using p_file sy-subrc.
  if sy-subrc ne 0.
    message e000 with 'File does not exist or Path+Filename > 128 chars'.
  endif.
*&---------------------------------------------------------------------*
*&      Form  CHECK_FILE_EXIST
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_SY_SUBRC  text
*----------------------------------------------------------------------*
form check_file_exist  using  p_file p_subrc.
  data: l_exist(1).

  call function 'DX_FILE_EXISTENCE_CHECK'
    exporting
      filename    = p_file
      pc          = 'X'  "if space then check is made in application server else in presentation server
    importing
      file_exists = l_exist.

  if l_exist ne 'X'.
    p_subrc = 8.
  endif.

endform.                    " CHECK_FILE_EXIST

Read only

Former Member
0 Likes
812

This message was moderated.

Read only

rainer_hbenthal
Active Contributor
0 Likes
811

What kind of server? Presenation server or application server?