2009 Mar 06 8:23 AM
Hello All,
I am having some requirment to find the file name for the input provided parameter.
In my program i am having an input parameter for file name. This contains both the file name and file stored location.
Example : C:\Dokumente und Einstellungen\xs234fs\Desktop\TEST_123_44.txt
From the above example string i need to find only the file name that is TEST_123_44.txt by using Regular expression.
Please let me know how to get this.
Thank you ver much in advance.
Thanks,
Feroz.
2009 Mar 06 8:28 AM
Not Sure about regular expression, but there is a FM which can split the file path:
PC_SPLIT_COMPLETE_FILENAME
Not Sure about regular expression, but there is a FM which can split the file path:
PC_SPLIT_COMPLETE_FILENAME
2009 Mar 06 8:27 AM
Hello,
If you have attached an F4 help to the filename input param, in that you can use the FM: GUI_FILE_SAVE_DIALOG.
In this there is a return param FILENAME which contains the name of the file.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'GUI_FILE_SAVE_DIALOG'
EXPORTING
window_title = TEXT-001
default_extension = p_extens
default_file_name = ls_deffile
initial_directory = ls_initdet
IMPORTING
filename = ls_filename "This contains the filemame
path = ls_path
fullpath = ls_fullpath
user_action = ls_usaction.Else if you have hardcoded the filename in the input field you can use rthe FM: PC_SPLIT_COMPLETE_FILENAME to split the filenames into different components
BR,
Suhas
Edited by: Suhas Saha on Mar 6, 2009 9:31 AM
2009 Mar 06 8:28 AM
Not Sure about regular expression, but there is a FM which can split the file path:
PC_SPLIT_COMPLETE_FILENAME
2009 Mar 06 8:30 AM
2009 Mar 06 8:36 AM
Hi Feroz,
There are many threads with the same question on SCN. Did you search before posting ?
regards,
Advait
2009 Mar 06 8:43 AM
Hello Advait Gode,
I have not see any Regular expression thread related to this. I have seen function modules.
I need this by Regular Expression.
Thanks,
Feroz.
2009 Mar 06 8:46 AM
2009 Mar 06 8:50 AM
Hi,
Pls see the code below:
DATA: LONG_FILENAME TYPE DBMSGORA-FILENAME,
PURE_FILENAME TYPE SDBAH-ACTID,
PURE_EXTENSION TYPE SDBAD-FUNCT.
DATA: SHIFTN TYPE I,
DEL_SLASH(1) VALUE '/',
DEL_POINT(1) VALUE '.'.
DO.
SEARCH LONG_FILENAME FOR DEL_SLASH.
IF SY-SUBRC > 0.
EXIT.
ENDIF.
SHIFTN = SY-FDPOS + 1.
SHIFT LONG_FILENAME BY SHIFTN PLACES LEFT.
ENDDO.
SPLIT LONG_FILENAME AT DEL_POINT INTO PURE_FILENAME PURE_EXTENSION.
CONDENSE PURE_FILENAME NO-GAPS.
CONDENSE PURE_EXTENSION NO-GAPS.
Keerthi
2009 Mar 06 9:06 AM
Before anyone else posts an answer, the original poster is wanting to know how do this using REGULAR EXPRESSIONS. Further references to split, or function modules will be deleted.
I'm tempted to remove the points, but seeing as the OP has seen fit to give them for the repeated wrong answers, that's up to him.
2009 Mar 06 9:13 AM
I've done a quick search on google, using keywords regex filename and it seems the best advice is to not use regex for this purpose as it is difficult construct one that catches all. I certainly couldn't find one that works.
matt
2009 Mar 06 10:10 AM
May i know which rule i broke while answering this question?..
2009 Mar 06 4:11 PM
I can't find any of your reply in the above posts.
can we smell something here ? ( If you are supporting for some other ...)
2009 Mar 06 4:13 PM
I am interested in possibility of finding a solution through regex expression .
I suggested a link which has been deleted.
So waiting for aRs
2009 Mar 06 8:39 AM
Hi Feroz,
See the following FM:
CALL FUNCTION 'SPLIT_FILENAME'
EXPORTING
LONG_FILENAME = DBMSGORA-FILENAME
IMPORTING
PURE_FILENAME = LOCAL_ACTID
PURE_EXTENSION = LOCAL_FUNCT.
Here PURE_FILENAME will give the name of the file(eg ABC>DOC) as ABC and PURE_EXTENSION will give the extension as DOC.
Keerthi
2009 Jul 24 12:47 PM
I was searching for the same thing but I didn't find it. It took a bit but I made one that works:
REPLACE ALL OCCURRENCES OF REGEX '[\w:\\,\\,\/][\w,\s,[:punct:]]*[\\,\/]' in l_str_file with ''.Edited by: Erik Peterson on Jul 24, 2009 7:47 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |