cancel
Showing results for 
Search instead for 
Did you mean: 

Upload a file to the DMS with MII

Former Member
0 Kudos

Hi Experts,

Am struggling trying to upload a file to the SAP DMS from MII. I can successfully create a document info record, but can't attach a file to that DIR from MII. I can upload and check-in a file successfully from my PC via SE37 and via CV01N.

I've tried using BAPI_DOCUMENT_CREATE2 and BAPI_DOCUMENT_CHECKIN2 with no success. My latest tests involve using the BAPI_DOCUMENT_CREATE2 to create the DIR and the BAPI_DOCUMENT_CHECKIN2 to specify the upload file and storage category and initiate the check-in.

I've attempted specifying the file as a local file on the MII server (C:\..), a local file on my client PC, and in a public directory on the network (
servername\folder...) all with no luck. I've tried copying the SAPFTP.EXE and SAPHTTP.EXE to the MII server and specifying SAPFTP and SAPHTTP in the request also with no luck. The CHECKIN BAPI returns no helpful error message.

Is it indeed possible to do this? Has anyone had any success successfully uploading and checking in a document? The SDN is mysteriously void on this topic. Am I missing something simple or is there another approach completely to initiate moving and checking in a document, triggered by MII?

If I had the choice, would like the file to originate on a client PC. But at this point am not picky, I can put the file anywhere so long as it can be uploaded and attached to a DIR successfully.

Thanks in advance,

Dave

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

This message was moderated.

agentry_src
Active Contributor
0 Kudos

Hi David,

Have you tried saving it in the workbench using web:// or possibly db://?

Regards,

Mike

Former Member
0 Kudos

Hi Mike,

I haven't tried saving a file in the MII file system because I don't know how to read it out with the BAPI. That is, if I wanted to upload a file stored in the MII file system then how would I describe the DOCFILE in BAPI_DOCUMENT_CHECKIN2?

No matter where the file is located I can't upload and check it into SAP when calling these BAPI_DOCUMENT* BAPIs from MII.

Any further advice is appreciated,

Dave

Former Member
0 Kudos

I have never heard of a working MII DMS integration implementation without some custom Java involved. You can look at my post [In this thread |; and possibly try to 'reverse' the process and send the contents of the file in a bapi call using CVAPI_DOC_CHECKIN or similar.

0 Kudos

Dave,

You are better off using the FTP interface of the DMS for uploading files. In the MII Wiki in the customization section are some actions for SFTP support if you need a secure interface.

Sam

Former Member
0 Kudos

Sam,

Is there any documentation on how to FTP files into the DMS? My guess is that this isn't so easy because would I need to get some ID back so that I could link that file to the DIR separately? Maybe am I misunderstanding your suggestion?

Alternatively I see the SAPFTP and HOSTNAME parameters associated with many of the DMS BAPIs (BAPI_DOCUMENT_CREATE2, e.g.) but assumed that this requires the use of the SAPGUI FTP client somehow. Can the MII FTP client be used in-place here somehow? How?

Also, if it matters, I'm looking to upload files from an MII client PC to the DMS. So, I presume that regardless I'd need to get the file from the client to the MII server or to an accessible network location. However, if this works then the FTP approach is likely easier than I'm about to describe below...

Christian,

I'm inclined to take the approach that you're implying, I think. I am able to DOWNLOAD the binary content (i.e. NOT file) of a file from the DMS and display it in a browser. In my latest attempt, I am taking the approach to reverse this process and pass the CONTENT back to SAP DMS via the CVAPI_DOC_CHECKIN. I successfully attached and checked in a file this way (major accomplishment!!!) but there is something wrong with the encoding, the file doesn't look the same as the original.

Two issues remain with this approach:

1) What type of encoding/format is SAP expecting? Do you have any ideas here?

2) How do you convert a PDF, TXT or other file type to that binary string format on the CLIENT (using Javascript hopefully)?

Thanks both for your helpful advice. I'm getting closer....

0 Kudos

Dave,

No idea on how just heard from other people that this works:

[|]

In the Asset Visibility Application on the Wiki i have a page for uploading files into MII and they appear as a Base64 encoded string of binary data.

Sam

Former Member
0 Kudos

So uploading a file to the DMS turned out to be more complicated than expected, but it works quite nicely. Here's the process that I followed:

1. On web page, created an input control of type file for user to browse and select a file on a local PC and a submit button. The form action must be the JSP page. You cannot post this via ajax or other method as far as I understand.

2. Call a JSP page (similar to the one that Sam pointed to in the Asset Visibility application) that reads in the data content from the selected file as base64-encoded binary stream.

3. From the JSP, call a transaction, passing the base64-encoded file content data as a string.

4. In the transaction, convert the base64-encoded string to a hex-encoded string, there may be other ways but I created an additional JSP to convert the string and used an HTTP Post action to call it from the transaction. I used the JSP that Christian references in this thread as a starting point.

5. Use CVAPI_DOC_CHECKIN to send the data to SAP. The hex-encoded data must be broken into chunks of 2550 bytes (or 5110 hex characters) and fed into the CONTENT table, the last chunk will be less than 2550 bytes and it must be specified how many bytes it includes. Return success/failure to from the TRX. The transaction must also create the Document Record if it doesn't exist already using BAPI_DOCUMENT_CREATE2.

6. Small trick: The original form post in step 1 will report the success/failure of the process in a new window by default. I created a hidden iFrame and posted with that as the target and included an onload function for the iFrame that reported the message back to the main page.

That's it! Careful, there's lots of areas to miss or truncate a byte with the string manipulation, which will result in an unreadable file in SAP. Be sure to test with TXT files as well as more complex MIME files (like XLS, etc.).

Dave

Former Member
0 Kudos

Hi david,

I am a requirement similar to yours.

1- I have to upload file in dms from local machine.

2- the .net person is doing coding to upload file in dms.

3- I need to give him any bapi so that he can upload file to dms. Is there any standard bapi available or i need to customize it. please let me know in detail how to do that as I am new to this.

Regards

Shilpa