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 filename to file and extension

Private_Member_19084
Active Contributor
0 Kudos

Hi experts,

Does any know a FM or class, which is released and I can use to get the file name and extension?

Normally I used the FM SPLIT_FILE.

But this FM does only exports CHAR3.

So I get a problem with new office-files (XLSX, DOCX)...

thx for any help

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Why dont u use just a split statement e.g.

Split file_name into f1 f2.

where f1 contains file name and f2 extension

and both f1 f2 are type string

10 REPLIES 10

arseni_gallardo
Active Participant
0 Kudos

Try with TRINT_FILE_GET_EXTENSION

0 Kudos

Thx for fast help.

I've already found this one.

But it is not release...

Isn't there a FM which is released?

thx

Former Member
0 Kudos

Why dont u use just a split statement e.g.

Split file_name into f1 f2.

where f1 contains file name and f2 extension

and both f1 f2 are type string

0 Kudos

Because it would be easier...

If the filmename for example is test.data.xlsx I would have to use a loop or do.

And so I would prefer a FM.

0 Kudos

Check PC_SPLIT_COMPLETE_FILENAME

Regards

Marcin

0 Kudos

Not necessarily, after splitting with '.' as separator, you can DESCRIBE table LINES and get the index of last row and use READ TABLE table INDEX index to get the extension.

That said, if you are on ECC you can do this elegantly with regular expressions. I will update my post later when I have time.

0 Kudos

What about a class method then?


  CALL METHOD CL_BCS_UTILITIES=>SPLIT_NAME
      EXPORTING
       iv_name = file_name
        iv_Delimiter = '.'
   importing
      ev_extension = lv_extension.

or CL_OLR3_DMS_WORK=>SPLIT_NAME_TO_EXTENSION

0 Kudos

Hi ,

Check CH_SPLIT_FILENAME FM as well. It is a released FM and should server your purpose .

Regards,

Arun

0 Kudos

hi ,

Data : f1(20) type c ,
           f2(5) type  c,
          c_tab  type c value  '.' .

data: f_name(30) type c value 'TEST.EXE' .

split  F_NAME AT C_TAB INTO F1 F2 .

Regards

Deepak.

0 Kudos

thx for fast help to everyone

btw: CH_SPLIT_FILENAME is NOT released (at least in our system ECC 605)