DATA:
 dot_offset TYPE i,
 extension  TYPE w3fileext,
 filename   TYPE char255 VALUE 'myTime.xlsx',
 mimetype   TYPE w3conttype.


 FIND FIRST OCCURRENCE OF REGEX '\.[^\.]+$'
   IN filename MATCH OFFSET dot_offset.

 IF sy-subrc EQ 0."File extension found
   ADD 1 TO dot_offset.
   extension = filename+dot_offset.

   "Get MIME type from file extension
   CALL FUNCTION 'SDOK_MIMETYPE_GET'
     EXPORTING
       extension = extension
     IMPORTING
       mimetype = mimetype.

 ELSE."File extension not found, set joker
   mimetype = 'application/octet-stream'.
 ENDIF.

Share this content: