09-16-2008 8:51 AM
Hi guys,
Is there an fm getting the file name with path given the physical path and file name? Thanks!
09-16-2008 9:10 AM
Hi Mark,
Function Module WS_FILENAME_GET is obsolete, dont use it.
Use the Method file_open_dialog of class cl_gui_frontend_services as given below.
DATA:
lt_filetable TYPE filetable,
lf_rc TYPE i,
lv_filename(50) TYPE c,
lv_fileext(3) TYPE c,
ls_file TYPE file_table,
lv_file TYPE localfile,
lv_title TYPE string.
lv_title = sy-title.
lv_progname = sy-cprog.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = lv_title
file_filter = '*.txt'
multiselection = abap_false
CHANGING
file_table = lt_filetable
rc = lf_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
* Number of selected filed must be equal to one.
CHECK lf_rc = 1.
* Access selected file
READ TABLE lt_filetable INTO ls_file INDEX 1.
CHECK sy-subrc = 0.
lv_file = ls_file-filename.
SPLIT lv_file AT '.' INTO lv_filename lv_fileext.
Revert back if you need clarifications.
Regards
Karthik D
09-16-2008 8:54 AM
Hi,
Please check the below code.
PARAMETERS : p_flnm LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FLNM.
perform F4_HELP.
FORM F4_HELP.
IF SY-UCOMM <> 'onli'.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
DEF_FILENAME = P_FLNM
DEF_PATH = 'c:\my documents'
MASK = ',*.*,*.*.'
MODE = 'O'
TITLE = 'Open PC File for Upload'
IMPORTING
FILENAME = P_FLNM
EXCEPTIONS
INV_WINSYS = 01
NO_BATCH = 02
SELECTION_CANCEL = 03
SELECTION_ERROR = 04.
IF SY-SUBRC <> 0.
MESSAGE E000(0) WITH 'error locating upload file on PC' P_FLNM.
ENDIF.
ENDIF.
ENDFORM.
Regards,
09-16-2008 9:00 AM
HI,
just use function module 'WS_FILENAME_GET'
it will definately help you.
THANKS AND REGARDS
Rahul Sharma
09-16-2008 9:03 AM
Hi...
can be down like this,,,
PARAMETERS: p_file TYPE ibipparms-path OBLIGATORY
DEFAULT 'C:\'.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
Regards,
sg
09-16-2008 9:04 AM
Hi,
The Function Module FILE_GET_NAME
Platform-independent file names are used in applications programs by the function module FILE_GET_NAME. For a given logical file name, the function module generates the corresponding platform-specific file name at runtime, based on definitions stored in customizing tables for converting platform-independent file names.
Hope this helps.
Thanks,
Rashmi.
09-16-2008 9:05 AM
Hi,
Try: CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG
Regards, Dieter
09-16-2008 9:10 AM
Hi Mark,
Function Module WS_FILENAME_GET is obsolete, dont use it.
Use the Method file_open_dialog of class cl_gui_frontend_services as given below.
DATA:
lt_filetable TYPE filetable,
lf_rc TYPE i,
lv_filename(50) TYPE c,
lv_fileext(3) TYPE c,
ls_file TYPE file_table,
lv_file TYPE localfile,
lv_title TYPE string.
lv_title = sy-title.
lv_progname = sy-cprog.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = lv_title
file_filter = '*.txt'
multiselection = abap_false
CHANGING
file_table = lt_filetable
rc = lf_rc
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
DISPLAY LIKE 'E'
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ENDIF.
* Number of selected filed must be equal to one.
CHECK lf_rc = 1.
* Access selected file
READ TABLE lt_filetable INTO ls_file INDEX 1.
CHECK sy-subrc = 0.
lv_file = ls_file-filename.
SPLIT lv_file AT '.' INTO lv_filename lv_fileext.
Revert back if you need clarifications.
Regards
Karthik D