Application Development 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: 

Split of string

Former Member
0 Kudos
174

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

matt
Active Contributor
0 Kudos
148

>

> i got it

>

> 'SO_SPLIT_FILE_AND_PATH'

>

> we can use this fm

So mark the question as answered.

9 REPLIES 9

Former Member
0 Kudos
148

i got it

'SO_SPLIT_FILE_AND_PATH'

we can use this fm

Former Member
0 Kudos
148

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.

matt
Active Contributor
0 Kudos
149

>

> i got it

>

> 'SO_SPLIT_FILE_AND_PATH'

>

> we can use this fm

So mark the question as answered.

faisal_altaf2
Active Contributor
0 Kudos
148

Hi, Matt

I think better to lock this now?

Thanks and Best Regards,

Faisal

former_member181962
Active Contributor
0 Kudos
148

Use the FM: PC_SPLIT_COMPLETE_FILENAME

The parameter FILE_WITH_EXT will give you what you wanted.

Regards,

Ravi

faisal_altaf2
Active Contributor
0 Kudos
148

Hi,

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

For Example

[1st Example|;

[2nd Example|;

Best Regards,

Faisal

Former Member
0 Kudos
148

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

Former Member
0 Kudos
148

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

Former Member
0 Kudos
148

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