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

Split of string

Former Member
0 Likes
1,060

Hi Experts,

I have a requirement that i need to capture the last word

For eg : i have a file name

c:/example/example2/hi.txt

i need to capture hi.txt into a variable

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
1,034

>

> i got it

>

> 'SO_SPLIT_FILE_AND_PATH'

>

> we can use this fm

So mark the question as answered.

9 REPLIES 9
Read only

Former Member
0 Likes
1,034

i got it

'SO_SPLIT_FILE_AND_PATH'

we can use this fm

Read only

Former Member
0 Likes
1,034

try this

DATA: it_file TYPE TABLE OF string,

wa_file LIKE LINE OF it_file,

w_lines TYPE i,

w_file1 TYPE string,

w_file2 TYPE string.

w_file1 = 'C:\Documents and Settings\abc.def\asdfgh\abcde\filename.csv'.

SPLIT w_file1 AT '\' INTO TABLE it_file.

DESCRIBE TABLE it_file LINES w_lines.

READ TABLE it_file INTO wa_file INDEX w_lines.

WRITE: wa_file.

Read only

matt
Active Contributor
0 Likes
1,035

>

> i got it

>

> 'SO_SPLIT_FILE_AND_PATH'

>

> we can use this fm

So mark the question as answered.

Read only

faisalatsap
Active Contributor
0 Likes
1,034

Hi, Matt

I think better to lock this now?

Thanks and Best Regards,

Faisal

Read only

Former Member
0 Likes
1,034

Use the FM: PC_SPLIT_COMPLETE_FILENAME

The parameter FILE_WITH_EXT will give you what you wanted.

Regards,

Ravi

Read only

faisalatsap
Active Contributor
0 Likes
1,034

Hi,

Please Search Before Posting there are lot of Threads Related to This Topic

For Example

[1st Example|;

[2nd Example|;

Best Regards,

Faisal

Read only

Former Member
0 Likes
1,034

hi ,

try to use the split statement .

example :

data : str type string ,

BEGIN OF t OCCURS 0,

line(10) TYPE c,

END OF t.

str = 'c:/example/example2/hi.txt' .

split str at '/' into TABLE t .

regards

Read only

Former Member
0 Likes
1,034

DATA: str1 TYPE string,

str2 TYPE string,

str3 TYPE string,

itab TYPE TABLE OF string,

text TYPE string.

text = `What a drag it is getting old`.

SPLIT text AT space INTO: str1 str2 str3,

TABLE itab.

Above one is example how to split and store that data in variables or in any internal table.

SPLIT (YOUR FILE PATH) AT '/' INTO ( VAR1 VAR2 VAR3).

Hope this help ful

Read only

Former Member
0 Likes
1,034

hi,

data temp type string,

file type string value 'c:/example/example2/hi.txt'.

temp = file.

revese temp.

search for '/' in temp .

if sy-subrc = 0.

find the index from starting to the index u can store in some other variable.

endif.

hope it will help u.

~linganna

Edited by: katigiri linganna on Apr 24, 2009 12:29 PM