Recently i was working on this requirement, and after searching SCN, i did not get a concrete set of steps to follow in orde to upload a document successfully into KM. This is a very common requirement these days, as customer needs to upload document for medical bills, expense receipts, vendor invoices etc for audit requirements.
I thought that this is my time to contribute back to the SCN community by giving my 2 cents. I cannot always look only for help.
Ok, so uploading the document into KM.
1. First thing that we need to have is the WSDL file for the KM server which we need to be able to create a web service in SAP. Once you have your hands on it, follow the below mentioned link to create the web service in ABAP.
2. Once the proxy class is ready then we need to create a custom wrapper class to call the methods of the proxy class to upload add / delete / modify the documents.
3. While uploading the document you need to create a reference of the logical port in the wrapper class in order to able to communicte to the webservice through that port. You can do that in the upload_document method.
4. Now we can class the main proxy class method in order to upload the document by populating some information from the method interface.
5. Certain fields such as content, length, document name, mime type, location path etc are supplied to the upload_document method interface.
6. Similarly in order to download the document from KM server use the method "get_content_metadata" of the proxy class created. For deleting use the method " delete_resource" of the prozy class and call it in the wrapper class.
7. Now in Web dynrpo, use the UI element FileUpload. With this UI element you will be able to browse for a file in your local machine i.e. browse button is inbuilt with this UI element.
8. Create a context with the following details.
- Filepath(char255)
- Filecontent(xstring)
- URL(char255)
- mimetype(char1)
9. Bind the above mentioend attributes to the UI element properties.
10. Add another button "Upload" and on action handler read the context attributes values and use them to call the below mentioned method of the wrapper class to upload the document.
11. If everything is fine, we can display a successfull message.
12. We can add another set of button to remove, and download attachments.
I hope you all like the blog and it serves as a single point of reference for you and it helps you to upload the documents into KM without much hasle.
Ashish