2005 Aug 16 9:12 PM
We need to search for a file name in a file path and then move the file to an application server.
Ex: C:\Documents\test.csv is the file path and we need to move the file test.csv to a specified location in the application server.
we are trying to use the available string functions, but they are not helpful.
Your help is highly appreciated.
THank you
2005 Aug 16 9:30 PM
Hi!
The function module PC_SPLIT_COMPLETE_FILENAME will split that field into its components, if that is all you need...
Cheers,
John
If the path and file name is always the same, then you can use some methods of the class CL_GUI_FRONTEND_SERVICES. To check if the file exists in the specified path, use the method FILE_EXIST. If it does exist, then use the method GUI_UPLOAD to load it into the program, then use ABAP statements OPEN DATASET and TRANSFER DATASET to write the file to the application server.
Regards,
Rich Heilman
2005 Aug 16 9:30 PM
Hi!
The function module PC_SPLIT_COMPLETE_FILENAME will split that field into its components, if that is all you need...
Cheers,
John
2005 Aug 17 12:05 AM
If the path and file name is always the same, then you can use some methods of the class CL_GUI_FRONTEND_SERVICES. To check if the file exists in the specified path, use the method FILE_EXIST. If it does exist, then use the method GUI_UPLOAD to load it into the program, then use ABAP statements OPEN DATASET and TRANSFER DATASET to write the file to the application server.
Regards,
Rich Heilman
2005 Aug 17 4:43 AM
Hi,
You can use this code to search the file name:
DATA: li_filetable TYPE STANDARD TABLE OF file_table,
lv_return TYPE i,
lw_filetable TYPE file_table.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select file for download'
default_extension = '.txt'
* DEFAULT_FILENAME = '.txt'
* file_filter = '*.txt ,*.txt.'
initial_directory = 'C:'
CHANGING
file_table = li_filetable
rc = lv_return
EXCEPTIONS
file_open_dialog_failed = 1
cntl_error = 2
error_no_gui = 3
OTHERS = 4
.
IF sy-subrc <> 0.
MESSAGE e003 WITH text-015.
ELSE.
READ TABLE li_filetable INTO lw_filetable INDEX 1.
p_fnam2 = lw_filetable-filename.
ENDIF.Also check out this link for downloading/ uploading data from presentation/application server.
http://www.sapdevelopment.co.uk/file/file_updown.htm
Best Regards,
Anjali
2005 Aug 17 5:07 AM
Hi,
U can use this fm to check the file existance.
CALL FUNCTION 'SXDA_FILE_EXISTENCE_CHECK'
EXPORTING
DS_NAME = P_FPATH
DATA_APP = 'X'
DATA_REM = SPACE
SERVER = SPACE
DATA_FRN = SPACE
PC_FILE = SPACE
IMPORTING
FILE_EXISTS = W_XFLAG
EXCEPTIONS
RFC_FAILURE = 1
FRONTEND_ERROR = 2
DB_ERROR = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
STOP.
ENDIF.
IF W_XFLAG EQ 'X'.WRITE:/001 'File exists'.ENDIF.
IF W_XFLAG NE 'X'.WRITE:/001 'File does not exist'.ENDIF.
Regds
gv
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |