Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FM required

Former Member
0 Likes
1,179

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.

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,113

hi Ravi,

what about using the SPLIT statement?

ec

8 REPLIES 8
Read only

JozsefSzikszai
Active Contributor
0 Likes
1,114

hi Ravi,

what about using the SPLIT statement?

ec

Read only

Former Member
0 Likes
1,113

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.

Read only

Former Member
0 Likes
1,113

Hi Ravi

use TRINT_SPLIT_FILE_AND_PATH Function Module

it is working for /

Regards

sandhya

Read only

0 Likes
1,113

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

Read only

Former Member
0 Likes
1,113

Instead try Function Module "TRINT_SPLIT_FILE_AND_PATH"

Read only

Former Member
0 Likes
1,113

You can consider replace all occurrence of "\" in your path with "/" before you execute SO_SPLIT_FILE_AND_PATH.


Cheers

Read only

hitesh_gabani
Participant
0 Likes
1,113

Hi Ravi,

I have found the fm DSVAS_DOC_FILENAME_SPLIT also very useful.


it work for both forward or backward slash


Regards,

Hitesh

Read only

Juwin
Active Contributor
0 Likes
1,113

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