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 type

Former Member
0 Likes
1,878

Hi,

Is there any FM/Method that returens the file type (TXT, XLS, DAT ...) for a specific file ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,806

try FILE_GET_NAME

or RZL_READ_DIR_LOCAL

9 REPLIES 9
Read only

Former Member
0 Likes
1,807

try FILE_GET_NAME

or RZL_READ_DIR_LOCAL

Read only

Former Member
0 Likes
1,806

No,

There is function module which returns the file path,

Cheers,

Chandru

Read only

Former Member
0 Likes
1,806

I don't think so...But you can do this...


DATA: FILE TYPE STRING,
      EXT(3) TYPE C,
      LONG TYPE I.

FILE = 'C:\DOCS\HELLO_WORLD.DOC'.

LONG = STRLEN( FILE ).
LONG = LONG - 3.
EXT = FILE+LONG(3).

WRITE:/ EXT.

You can make a custom FM...

Greetings,

Blag.

Read only

Former Member
0 Likes
1,806

Hi,


check FM  /SAPSLL/CORE_KPRO_FILE_EXT_GET


REPORT ztest_cha1.

DATA : v_ext TYPE string.

CALL FUNCTION '/SAPSLL/CORE_KPRO_FILE_EXT_GET'
  EXPORTING
    iv_file_string    = 'TEMP1.TXT'
  IMPORTING
    ev_file_extension = v_ext.

SHIFT v_ext LEFT.

WRITE : v_ext.

Read only

Former Member
0 Likes
1,806


also try this'

REPORT ztest_cha1.

DATA: lext(3) TYPE c,
      lfile LIKE pcfile-path.

MOVE 'TEMp1.XLS' TO lfile.

CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
  EXPORTING
    complete_filename = lfile
  IMPORTING
    extension         = lext.

WRITE : lext.

Read only

Former Member
0 Likes
1,806

Thanks for all your answers.

Somtimes the file name doesn't contain the the file type (abc.txt or just abc). so the last 4 characters won't contain the file type.

Read only

0 Likes
1,806

Hi Rotem,

Have you find the answer?

Now i have the same requirement. Can you please share the answer?

...Naddy

Read only

0 Likes
1,806

see

...Naddy

Read only

0 Likes
1,806

Hi Naddy,

I have forced the user to enter a file name with the wanted extension.

I haven't found a way to get the file type without an extension