2007 Nov 26 9:28 PM
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.
2007 Nov 26 9:34 PM
2007 Nov 26 9:36 PM
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