You might have a task to use or download one or all files attached to document saved via CV01N transaction. This is not a big deal really, you just need to use some FMs available in standard of SAP like 'CVAPI_DOC_GETDETAIL', 'CVAPI_DOC_CHECKOUTVIEW' or SCMS_DOC_READ'. These FMs allows you the check the details of document, check it and then read its content. Of course sometimes you'll have to zip the files before the downloading and here in my code I used method "zip" for which code you can find here. While reading the code you may also find another Z-method called "get_filename_from_path", its code is posted here. The method I'm posting bellow allows you to choose if during download of files from document you want to zip them all together into one zip file or if you want to zip them separatelly. In table ET_FILES you'll find all files that were attached to document, field "UPDATEFLAG" will be set to if file was succesfully downloaded to PC. If you don't want to download the file but you want to get it for futher use you'll have to request ET_XSTRING table. In other case do not request this parameter as it is a sign for method that you don't want to donwload the files.
Types:
TT_RA_FILENAME type range of CVAPI_DOC_FILE-FILENAME.
TT_XSTRING type table of xstring.
Importing:
I_DOKAR TYPE DRAW-DOKAR
I_DOKNR TYPE DRAW-DOKNR
I_DOKTL TYPE DRAW-DOKTL
I_DOKVR TYPE DRAW-DOKVR
I_DOWNLOAD_DIRECTORY TYPE STRING -
I_ZIP_FILES TYPE C OPTIONAL
I_ZIP_SEPARATELY TYPE C OPTIONAL
I_NAME_FILTER TYPE TT_RA_FILENAME OPTIONAL
I_FILENAME TYPE CSEQUENCE OPTIONAL
Exporting:
ET_FILES TYPE CVAPI_TBL_DOC_FILES
ET_XSTRING TYPE TT_XSTRING -> TT_XSTRING
Exceptions:
ZIP_ERROR
DOCUMENT_ERROR