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: 

File extension

former_member622551
Participant
0 Kudos

Hello,

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

Thanks.

1 ACCEPTED SOLUTION

former_member188685
Active Contributor
0 Kudos

Try the Function module

PC_SPLIT_COMPLETE_FILENAME

6 REPLIES 6

Former Member
0 Kudos

Hi

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

FM not required.

With Regards,

Dwaraka.S

Former Member
0 Kudos

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.

Former Member
0 Kudos

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

former_member622551
Participant
0 Kudos

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

bpawanchand
Active Contributor
0 Kudos

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

former_member188685
Active Contributor
0 Kudos

Try the Function module

PC_SPLIT_COMPLETE_FILENAME