cancel
Showing results for 
Search instead for 
Did you mean: 

Download Documents from DMS in xMII

Former Member
0 Kudos

Hi,

I need to download some documents from SAP which are maintained in DMS.

I know there are some BAPIs like BAPI_DOCUMENT* and I know how to use them in ABAP , ITS and webapplication server.

But I am not able to think of how to do it in xMII.

Can some one share the details.

Thanks,

Amara.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You said you are aware of the BAPIs , so exactly where are you stuck? Is it calling the BAPI from xMII? I am sure that is not the issue as you have been around this forum for a while!

Providing a better explanation of the issue would help others help you.

Also what R/3 (or ECC) version are you trying to hit?

Former Member
0 Kudos

Udayan Upreti,

I have mentioned in detail to the Rick's reply. Please refer to it. Let me know if you still need more info.

Thanks for your time.

Srinivas.

0 Kudos

Srinivas,

Actually there is what you can do is set the string encoded content of the document response to a String type output of the transaction. Then call window.open and the transaction URL call. This should stream the document content into the newly opened web page. Just be aware that the content may or may not be base64 encoded. If it is simply use the base64decode() function in the BLS link editor to decode the document string.

Hope this helps.

-Sam

Former Member
0 Kudos

Sam,

In this approach can we set any header fields of http response.

Here is why I am asking this. In our company documents can be of any type like XLS,PDF,DOC ...etc. Is there any way to tell the browser to open the streamed content in a particular application. This is all because the content in internal table is about data not about meta data.

Great thought Sam.

Thanks,

Srinivas.

0 Kudos

Srinivas,

The issue here is that the DMS request actually returns something called multipart/form-data from the Content Managment system which can actually have multiple different document types all in the same streamed response from a single document reference, just something to keep in mind.

If you have a 1-to-1 setup where 1 document id references a single file then you can set the Content-Type then you can lookup the type of the document before you request the document and use this in the request URL, IE will do the rest.

-Sam

0 Kudos

Srinivas,

The BAPI to lookup the Application the document is expecting to be loaded with is:

BAPI_DOCUMENT_GETDETAIL2

You'll see a return item called WSAPPLICATION and APPLICATION_ID these are based on the ERP configuration for the various applications used to open the different document types.

Hope this helps.

-Sam

Former Member
0 Kudos

Sam,

I developed transaction needed to do streaming of data as you suggested.

It is pushing the data to the browser and opening it in the corresponding application. But it is showing junk data. It looks like there is some conversion going on. FM is returning the data in type X ( SAP data type - hexadevimal ).

I tried using base64decode and base64encode also. But no luck. Do you have any other thoughts.

Thanks,

Srinivas.

0 Kudos

Srinivas,

Most likely it's because the datastream is incomplete, when we did this before the data being returned from the ABAP API would only return a portion of the data for each call. So we had to create a temporary variable and append the next set of HEX values to the previous HEX values and then base64decode the entire string.

For example, using a string local property called imageString:

while(BAPI.HasMoreData) {

imageString = imageString & nextValuesFromBAPI

}

imageString = base64decode(imageString)

I also believe that it may be possible to do the string concatenation in the ABAP and also the base64decode as well, this may be the more efficient approach.

Also, during testing I would not stream the data back as a string output yet. Instead use the ImageSaver action and map the string content of the image to the ImageSave.EncodedImage value and write the image to somewhere in the webroot of the server. This should help your development effort.

-Sam

Former Member
0 Kudos

Getting close Sam, But with file write action block. I think there is some problem in decode/encode. Here is what I found. I am supposed to download excel file from DMS. When I opened the file which is just created by our transaction I can see the text data with in the cells along with some other junk.

I think we are close but some thing is missing ( may in concatenation or encode/decode etc..)

Any thoughts.

Srinivas.

0 Kudos

Srinivas,

The document is still probably XML encoded as well, do you have a sample of what the garbled data looks like?

-Sam

Former Member
0 Kudos

Sam,

Is it possible to send your email id to mail_to_srini@yahoo.com. I will reply back with the file and screen shots. I don't see any other way to upload files in SDN. This is why I am asking your id.

Thanks,

Srinivas.

Former Member
0 Kudos

Sam,

I just sent you a mail with file attachements.

Thanks in advance for your time.

Srinivas.

0 Kudos

Srinivas,

I replied to your email with some issues that I noticed, but I wanted to post them on the fourm as well for the benefit of the community.

In your transaction you were performing the base64decode() on each line coming back from the DMS individually. Instead of doing this concatenate all of the document strings returned from the BAPI/RFC and then perform the base64decode on the complete string.

For example instead of doing this in your transaction:

for(int i=0; i<RFCResponse.length; i++) {

Local.document & base64decode(RFCResponse.string)

}

return Local.document

Do this:

for(int i=0; i<RFCResponse.length; i++) {

Local.document & RFCResponse.string

}

return base64decode(Local.document)

Also, in your URL to call the transaction you have the content type set to application/doctype. Since you know that this is an Excel document being returned you should set the content type to application/x-msexcel. This way windows will be able to determine what to associate the file with.

Hope this helps, please let me know if you have any other questions about this.

-Sam

Former Member
0 Kudos

Sam,

Thanks for the reply,

I modified transaction according to your suggestion but still it is showing in same way garbled data.

Just to be more clear about what I am doing.

Below I copied script code that I was using to call transaction.

Regarding content-type:- I am pulling this value from SAP using the FM BWWF_GET_MIME_TYPE. To this FM if we pass "XLS" it will return "application/x-msexcel". This is nothing but what it is configured in SAP for this MIME type. Unfortunately in our system it is configured to "application/msexcel" instead of "application/x-msexcel". I discovered this after seeing your reply.

urlstring = "&DOC_TYPE="+document.user_attr.getPropertyValue("DOC_TYPE");

urlstring = urlstring + "&DOC_NO="+document.user_attr.getPropertyValue("DOC_NO");

urlstring = urlstring + "&DOC_VER="+document.user_attr.getPropertyValue("DOC_VER");

urlstring = urlstring "&DOC_PART="document.user_attr.getPropertyValue("DOC_PART");

urlstring=urlstring "&content-type="document.user_attr.getPropertyValue("content_type");

window.location.assign("http://xxxx/Lighthammer/Runner?Transaction=DASHBOARD/GET_DOCUMENT_TRAN&OutputParameter=FILE"+urlstring);

I appreciate your help.

Thanks,

Srinivas.

0 Kudos

Srinivas,

Can you please post the raw string ResponseXML from the BAPI/RFC call. Thanks.

-Sam

Former Member
0 Kudos

Sam,

I modified my transaction in order to save what exactly I am getting from SAP to xMII using an image saver action block to some folder with xxxx.xls file name.

Just because of my curiosity I double clicked on the file that is just created by our transaction. It opened <b>PERFECTLY WELL</b> in MS Excel.

So your question about asking to post garbled data clarified one of the two questions I have. Is the data getting corrupted while transmitted from SAP to xMII or is the data getting corrupted while transmitted from xMII to browser.

From the above modification to transaction of saving the file to a folder and opening it in MS Excel confirmed that the data is not getting corrupted while transmitting it from SAP to xMII. From now on we have only one thing to deal with i.e. that the data from xMII to Browser.

To confirm this, I created a test transaction with only one action block with ImageLoader and in the outgoing parameters I assigned imagedata property to transaction output property FILE. and I accessed it from browser using the below URL http://xxxx/Lighthammer/Runner?OutputParameter=FILE&Transaction=TEST_DOC_TRAN&content-type=applicati... . In this case also it is showing garbled data. Just to save you time I have send you transaction and test XLS file can be of any XLS file. Just to let you know that I have configured imageloader to load file from c:\inetpub\wwwroot\ directory.

Let me know if I need to provide more info.

Thanks in advance.

Srinivas.

0 Kudos

Srinivas,

Try using this URL: http://xxxx/Lighthammer/Runner?OutputParameter=FILE&Transaction=TEST_DOC_TRAN&content-type=applicati... . You also shouldn't have to do the base64decode on the FILE output parameter anymore. Please let me know if this works.

-Sam

0 Kudos

Srinivas,

One more thing, there is a bug here, you can't specify the Output parameter directly you have to use the * character.

You're URL should be this: http://xxxx/Lighthammer/Runner?OutputParameter=*&Transaction=TEST_DOC_TRAN&content-type=application/...

This means that you can have only one output, hope this helps.

-Sam

Answers (3)

Answers (3)

Former Member
0 Kudos

Amara

I've been unable to get BAPI_DOCUMENT* to work at all, could you maybe post an example of the links from your action block? Or if you could take a look at my settings here

Link: [;

and tell me what I'm doing wrong.

Any help would be much appreciated!

Thanks

Nick

Former Member
0 Kudos

Thank you Sam.

It is WORKING in both ways. OutputParameter =FILE or OutputParameter=*. Your help will add a lot to my development.

Is this "IsBinary=true" something related to MS IIS or xMII. I never used it before.

Thank you very much,

Srinivas.

0 Kudos

Srinivas,

Sure happy to help, and happy you got it working; the IsBinary parameter is an xMII feature.

-Sam

Former Member
0 Kudos

I haven't done it, but one of our partners, CIBER, has done quite a bit of work extracting documents from DMS using xMII BLS and displaying them in xMII pages.

Former Member
0 Kudos

Welcome Rick,

Here is what I was thinking of doing it. Using one of the BAPI related to DMS I can FTP the Document to xMII server wwwroot and open up a window with the URL to the above file.

Here is what my concern is . Since I am saving the document what ever the user request on to a folder in webserver it is going to eat up server space soon. I have some other function modules which can give me the document in an internal table to xMII BLS. But I do not know how to push this internal table data to an application on desktop to be opened in a browser.

What I am looking is , Is there any other way to show the document in web browser with out saving it at any where.

Rick can you share your thoughts on this. If you say that above approach of first saving it and displaying is the best as of now then I will proceed on that.

Thanks,

Srinivas.

Former Member
0 Kudos

Hi, Srinivas.

One approach is to create a "house cleaning" BLS transaction that can be run in the BLS scheduler periodically (perhaps once per hour?) and can delete files in a certain directory that are older than some specified time interval.

Best regards,

Rick