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

String Manipulation

Former Member
0 Likes
547

I need to extract the file type from the name of a file. For example:

C:\dir\files\filename.txt

extension = txt

D:\filedir\morefiles\filename.html

extension = html

What is the best way to do this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
519

Hi,

You can use the function module CH_SPLIT_FILENAME

Give the file name as input.

It will split and get you the extension..

Thanks,

Naren

3 REPLIES 3
Read only

Former Member
0 Likes
519

HI

FIND statement

DATA:

c TYPE STRING,

p(1) TYPE C,

off TYPE I,

len type i,

ext type string.

c = 'C:\filename.txt'.

p = '.'.

FIND p IN c MATCH OFFSET off.

len = off + 1.

ext = c+len.

write ext.

OR

DATA: C LIKE SDBAH-ACTID,

EXT LIKE SDBAD-FUNCT.

CALL FUNCTION 'SPLIT_FILENAME'

EXPORTING

long_filename = 'C:\FILENAME.TXT'

IMPORTING

PURE_FILENAME = C

PURE_EXTENSION = EXT

.

WRITE: C, EXT.

Regards

SAB

Read only

Former Member
0 Likes
520

Hi,

You can use the function module CH_SPLIT_FILENAME

Give the file name as input.

It will split and get you the extension..

Thanks,

Naren

Read only

0 Likes
519

try this one

SO_SPLIT_FILE_AND_PATH

gives u the path and the filename

Regards