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

Get file patch from string

Former Member
0 Likes
960

Hi,

i have this string and i always want the last charter in it,

after the last ' \ ' what is the best way to do that

C:\Documents and Settings\P508635\Desktop\*Book1.xls*

e.g.

here i want to get in tmp = Book1.xls

Regards

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
919

Hi

There are many Function Modules,

One on that is SO_SPLIT_FILE_AND_PATH

regards

Kumar M

7 REPLIES 7
Read only

JozsefSzikszai
Active Contributor
0 Likes
919
DATA : gv_lies TYPE i.
SPLIT file INTO TABLE itab AT '/'. "split the file name into internal table
gv_lines = lines( itab ). "determine the number of lines
READ TABLE itab INDEX gv_lines. "last line is what we need
Read only

0 Likes
919

HI Eric,

Read only

0 Likes
919

HI Eric,

I try your soltion and in the line :

SPLIT file INTO TABLE itab AT '/'. "split the file name into internal table

i change it to : SPLIT gv_filename AT '/' INTO TABLE itab. for avoid error .

but it don't split it u have idea?

Regards

Read only

Former Member
0 Likes
920

Hi

There are many Function Modules,

One on that is SO_SPLIT_FILE_AND_PATH

regards

Kumar M

Read only

0 Likes
919

sorry, my mistake, it has to be '\' (not '/')

Read only

Former Member
0 Likes
919

hi,

i think in place of forward slash '/' u have to use backward slash '\' i suppose....

Rgds.,

subash

Read only

Former Member
0 Likes
919

Hi ,

The below code works...

p_str =

C:\Documents and Settings\P508635 \Desktop\*Book1.xls*

data:str2(100) type c,

str3(100) type c,

str4(100) type c.

call function 'STRING_REVERSE'

exporting

string = p_str

lang = 'E'

importing

rstring = str2

exceptions

too_small = 1

others = 2.

if sy-subrc <> 0.

clear str2.

endif.

split str2 at '\' into str3 str4.

clear str4.

call function 'STRING_REVERSE'

exporting

string = str3

lang = 'E'

importing

rstring = str4

exceptions

too_small = 1

others = 2.

if sy-subrc <> 0.

clear str4.

endif.

p_str = str4.

Regards,

Kiran Bovindala.