Determine MIME type in ABAP

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.
SAPDEV.EU
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.