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

File extension

Former Member
0 Likes
1,604

Hello,

is there any class or FM that allow to get file extension?

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,221

Try the Function module

PC_SPLIT_COMPLETE_FILENAME

6 REPLIES 6
Read only

Former Member
0 Likes
1,221

Hi

I think u can use SPILT AT '.' in file name variable to get file extension.

FM not required.

With Regards,

Dwaraka.S

Read only

Former Member
0 Likes
1,221

Hi,

No sush FM as per my search.

One suggestion is, get the file name in a variable,

then split it into two.

example:

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.

Read only

Former Member
0 Likes
1,221

Hi,

You can do it with a small code.

Once you get the file name get the string length. From the string lenth get the last three letter of the file name it will give you your extenstion.

Example : W_fnam(100) type c value 'D:\test.txt',

w_strlen type i,

w_ext(3) type c.

w_strlen = strlen (w_fnam).

w_strlen = w_strlen - 3.

w_ext = w_strlen+0(3).

write: w_ext.

The output is TXT.

Regards,

Pramod

Read only

Former Member
0 Likes
1,221

May be the folder has a '.' in its name. I thinks that this solution doesn´t work in my system.

Read only

bpawanchand
Active Contributor
0 Likes
1,221

Hi

Use the FM

SODIS_GET_FILE_EXTENSION

Give the eniter fielname as the input eg; SAMPLE.DAT then the output will be .DAT

regards

Pavan

Read only

Former Member
0 Likes
1,222

Try the Function module

PC_SPLIT_COMPLETE_FILENAME