How to retrieve Mime Type of File in ABAP ? ( SAP Mime Types Tables)

Mime Type in SAP

This article will guide through how to retrieve Mime Type of any file using ABAP Program.

First, let’s deal with some definition ( what’s mime type ? ). Then we will list the most important tables in SAP for MimeTypes.
The last part will cover how to retrive, for a particular file, the mime type using standard SAP functions.

What’s MimeType ?

A media type (also MIME type and content type) is a two-part identifier for file formats and format contents transmitted on the Internet.
Media type consists of top-level type name and sub-type name, which is further structured into so-called “trees”. Media types can optionally define companion data, known as parameters.(1)

top-level type name / subtype name [ ; parameters ]
top-level type name / [ tree. ] subtype name [ +suffix ] [ ; parameters ]

Read also Sample ABAP Program for Application server File

List of Standard MimeType in SAP ?

First, let’s list the main SAP Tables for MimeTypes:

TableDescription
MIMETYPESTable of MIME types
SDOKMIMEMIME content type for file name enhancement
SDOKMIME_CMIME content type for file name enhancement (customer table)
SDOKMIMSMIME Content Type Replacement for Display/Editing
SDOKMIMS_CMIME Content Type Replacement (Customer Table)

SAP Mime Type Table MIMETYPES

The table in SAP for Mime Type is MIMETYPES.
MIMETYPES: Table of MIME types.

It has 2 fields:

  • TYEPE: HTML Content Type
  • EXTENSION: file name Extension

SDOKMIME SAP Mime Type Table

In the above table (MIMETYPES) is empty in your SAP System. Check the SAP Table SDOKMIME.
It has the same fields.

List of MimeType in SAP

All the mime Type description can be found in SAP Table SDOKFEXTT ( Text Table for SDOKFEXT ).

For example, for SAP MimeType “text/plain”, the description will be “Plain Text”

SAP Mime Type Description Table SDOKFEXTT

ExtensionSAP Mime Type
aiapplication/postscript
aifaudio/x-aiff
aifcaudio/x-aiff
aiffaudio/x-aiff
asctext/plain
asfvideo/x-ms-asf
asptext/asp
asxvideo/x-ms-asf
auaudio/basic
avivideo/avi
bmpimage/bmp
bsptext/html
btfimage/prs.btif
btifimage/prs.btif
ctext/plain
cctext/plain
cgmimage/cgm
cpptext/plain
csstext/css
dcrapplication/x-director
derapplication/x-x509-ca-cert
docapplication/msword
docmapplication/vnd.ms-word.document.macroenabled.12
docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
dotapplication/msword
dotmapplication/vnd.ms-word.template.macroenabled.12
dotxapplication/vnd.openxmlformats-officedocument.wordprocessingml.template
dtdtext/xml
dviapplication/x-dvi
epsapplication/postscript
fpximage/vnd.fpx
gifimage/gif
gzapplication/x-gzip
htext/plain
hhtext/plain
hlpapplication/winhelp
hpptext/plain
htmtext/html
htmltext/html
icoimage/ico
icstext/calendar
iefimage/ief
igesmodel/iges
igsmodel/iges
initext/plain
jarapplication/java-archive
jpeimage/jpeg
jpegimage/jpeg
jpgimage/jpeg
jsapplication/x-javascript
jsptext/html
latexapplication/x-latex
meshmodel/mesh
midaudio/mid
midiaudio/mid
mifapplication/mif
movvideo/quicktime
mp3audio/mpeg
mpevideo/mpeg
mpegvideo/mpeg
mpftext/vnd.ms-mediapackage
mpgvideo/mpeg
mppapplication/vnd.ms-project
mpxapplication/vnd.ms-project
mshmodel/mesh
odaapplication/oda
p7mapplication/pkcs7-mime
p7sapplication/pkcs7-signature
pdfapplication/pdf
plapplication/x-perl
pngimage/png
potmapplication/vnd.ms-powerpoint.template.macroenabled.12
potxapplication/vnd.openxmlformats-officedocument.presentationml.template
ppaapplication/vnd.ms-powerpoint
ppamapplication/vnd.ms-powerpoint.addin.macroenabled.12
ppsapplication/vnd.ms-powerpoint
ppsmapplication/vnd.ms-powerpoint.slideshow.macroenabled.12
ppsxapplication/vnd.openxmlformats-officedocument.presentationml.slideshow
pptapplication/vnd.ms-powerpoint
pptmapplication/vnd.ms-powerpoint.presentation.macroenabled.12
pptxapplication/vnd.openxmlformats-officedocument.presentationml.presentation
ppzapplication/vnd.ms-powerpoint
psapplication/postscript
qtvideo/quicktime
raaudio/x-pn-realaudio
ramaudio/x-pn-realaudio
rgbimage/x-rgb
rmaudio/x-pn-realaudio
rtfapplication/rtf
rtxtext/richtext
sapapplication/x-sapshortcut
scmapplication/x-screencam
silomodel/mesh
simapplication/vnd.sap_kw.itutor
sitapplication/x-stuffit
sltext/vnd.wap.sl
sndaudio/basic
splapplication/x-futuresplash
svgimage/svg+xml
swaapplication/x-director
swfapplication/x-shockwave-flash
tarapplication/x-tar
texapplication/x-tex
thttext/thtml
thtmtext/thtml
thtmltext/thtml
tifimage/tiff
tiffimage/tiff
tsfapplication/vnd.ms-excel
txttext/plain
vcftext/x-vcard
vcstext/x-vcalendar
vdovideo/vdo
vivvideo/vnd.vivo
vrmlmodel/vrml
vsdapplication/vnd.visio
wavaudio/x-wav
wbmptext/vnd.wap.wbmp
wmfapplication/x-msmetafile
wmltext/vnd.wap.wml
wmlstext/vnd.wap.wmlscript
wp5application/wordperfect5.1
wrlmodel/vrml
xapapplication/x-silverlight-app
xbmimage/x-xbitmap
xifimage/vnd.xiff
xlamapplication/vnd.ms-excel.addin.macroenabled.12
xlsapplication/vnd.ms-excel
xlsbapplication/vnd.ms-excel.sheet.binary.macroenabled.12
xlsmapplication/vnd.ms-excel.sheet.macroenabled.12
xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
xltmapplication/vnd.ms-excel.template.macroenabled.12
xltxapplication/vnd.openxmlformats-officedocument.spreadsheetml.template
xmltext/xml
xsdtext/xml
xsltext/xml
zipapplication/x-zip-compressed

How to retrieve Mimetype of a file in ABAP ?

In standard, SAP offers different function module to retrieve the Mime Type of a file in ABAP.

Let’s list the most used ones:

SKWF_MIMETYPE_OF_FILE_GET

The first function module is SKWF_MIMETYPE_OF_FILE_GET. It takes the filename in input and generates the Mime Type as output.
Here the signature of SKWF_MIMETYPE_OF_FILE_GET.

function skwf_mimetype_of_file_get.
*"----------------------------------------------------------------------
*"*"Lokale Schnittstelle:
*"  IMPORTING
*"     VALUE(FILENAME) TYPE  SKWF_FILNM
*"     VALUE(X_USE_LOCAL_REGISTRY) TYPE  SKWF_FLAG OPTIONAL
*"  EXPORTING
*"     VALUE(MIMETYPE) TYPE  SKWF_MIME
*"----------------------------------------------------------------------

Others SAP function for MimeType

Here we list other interesting functions in SAP for MimeType:

  • SDOK_MIMETYPE_GET_DESCRIPTION: Get MimeType Description
  • LXE_PC_READ_MIMETYPES : Definierte MIME-Types lesen
  • LXE_TS_API_GET_TS_MIMETYPES : Get a list of supported MIME types
  • SA_KW_RFC_MIMETYPE_GET
  • SMD_RFC_MIMETYPE_GET : ad mimetype from file extension

Note that this function module will retrieve the extension of the file, then it will call the SDOK_MIMETYPE_GET.

(1): Media Type in Wikipedia