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: 

file path not found

Former Member
0 Kudos
445

hi

i am using

parameters:p_file like rlgrap-filename,

to read the path for the file,

if the file is not found.

it should mention enter correct file path.

how do i handle this scenario.

2 REPLIES 2

Former Member
0 Kudos
170

Hi Sanjana,

Check this

Regards,

Satish

naimesh_patel
Active Contributor
0 Kudos
170

You can check the SY-SUBRC returned form the UPLOAD FM.

Like:

  DATA: L_FILE TYPE STRING.
  L_FILE = P_LFILE.

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
    EXPORTING
      FILENAME            = L_FILE
      HAS_FIELD_SEPARATOR = 'X'
    CHANGING
      DATA_TAB            = IT_FILE
    EXCEPTIONS
      FILE_OPEN_ERROR     = 1
      FILE_READ_ERROR     = 2
      OTHERS              = 18.
  if sy-subrc <> 0.       "<<
    message e398(00) with 'Error while opening a file'.
  endif.

You can add the File Selection Pop up for the file on the presentation server.

Like:


PARAMETERS:       P_LFILE TYPE CHAR70 OBLIGATORY.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_LFILE.
  PERFORM F4_LOCAL_FILE.


FORM F4_LOCAL_FILE .

  DATA: LT_FILES TYPE FILETABLE,
        LW_FILES TYPE FILE_TABLE,
        RC       TYPE SY-SUBRC,
        L_TYPE   TYPE STRING.

  L_TYPE = '*.txt'.

  CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
    EXPORTING
      WINDOW_TITLE            = 'Raw data for RFBIBL00'
      DEFAULT_FILENAME        = L_TYPE
    CHANGING
      FILE_TABLE              = LT_FILES
      RC                      = RC
    EXCEPTIONS
      FILE_OPEN_DIALOG_FAILED = 1
      CNTL_ERROR              = 2
      ERROR_NO_GUI            = 3
      OTHERS                  = 4.
  IF SY-SUBRC <> 0.
    MESSAGE E398(00) WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

* Get file selected
  READ TABLE LT_FILES INDEX 1 INTO LW_FILES.
  MOVE LW_FILES-FILENAME TO P_LFILE.

ENDFORM.                    " F4_local_file

Regards,

Naimesh Patel