‎2007 Sep 27 10:14 AM
Hi Experts,
Is there ant FM or method available in ECC6.0 to split a filename and its path?
For Ex: if i give: /test.txt. it should spliti into / and test.txt..Iknow there is FM SO_SPLIT_FILE_AND_PATH.But it is working with only \ it is not woking with forward slash like '/'.
Regards
Ravi.
‎2007 Sep 27 10:15 AM
‎2007 Sep 27 10:15 AM
‎2007 Sep 27 10:16 AM
Hi,
data: file(255), path(100), name(100) .
file = 'c:\desktop\ file.doc'.
CALL FUNCTION 'SO_SPLIT_FILE_AND_PATH'
EXPORTING
FULL_NAME = file
IMPORTING
STRIPPED_NAME = name
FILE_PATH = path
EXCEPTIONS
X_ERROR = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
write:/ name.
Thanks,
Reward If Helpful.
‎2007 Sep 27 10:25 AM
Hi Ravi
use TRINT_SPLIT_FILE_AND_PATH Function Module
it is working for /
Regards
sandhya
‎2007 Sep 27 10:33 AM
Hi ,
Thanks But it will not work.
Because if are getting data from application server .
For example if the path is like: /usr
In this case it is not splitting.
Regards
‎2015 Jul 08 6:06 AM
‎2015 Jul 08 6:20 AM
You can consider replace all occurrence of "\" in your path with "/" before you execute SO_SPLIT_FILE_AND_PATH.
Cheers
‎2015 Jul 08 6:52 AM
Hi Ravi,
I have found the fm DSVAS_DOC_FILENAME_SPLIT also very useful.
it work for both forward or backward slash
Regards,
Hitesh
‎2015 Jul 08 2:37 PM
In order to find what is the folder separator used by the operating system, you may use:
For a application server path: DMC_MDS_GET_PATHSEPARATOR
For a presentation server path: cl_gui_frontend_services=>get_file_separator
Once you have the separator....
Suppose your input path is: \\servername\path\file.xls
Use STRING_REVERSE function module to reverse the path. The output of this function module will be slx.elif\htap\emanrevres\\
Now, split the output at the separator. Thus, you will get 2 seperate strings - slx.elif and htap\emanrevres\\.
Now use again STRING_REVERSE to reverse both these strings, and thus you will have file.xls and \\servername\path, which is your filename and path.
Thanks,
Juwin