cancel
Showing results for 
Search instead for 
Did you mean: 

Word Document in XML tag.

Former Member
0 Kudos

Hi,

I have a requirement where I need to retrieve a word document in solution manager, and add the content in an xml tag.

Is this possible?

I managed to retrieve the document and converted into binary format and ready to send it via abap proxy.

Is it possible to load the data content in an xml tag? How do i do that?

Regards

Krish

Accepted Solutions (1)

Accepted Solutions (1)

Harish
Active Contributor
0 Kudos
Former Member
0 Kudos

Hello Harish,

Thanks for the links.

My question is mainly not about converting binary to xml but will it practically work when you convert a word document into binary and display it to xml code.

The binary file will not only contain the data of the document but also all its attributes. When I display it in XML, I am not sure whether only the data will be present or also all its attributes.

Remember, we are not converting word document into text file or csv, we are just converting from doc to binary to xml. Imagine, what will happen if it is a pdf or image file.

Regards

Krish

Harish
Active Contributor
0 Kudos

Hi Krish,

I never worked with Word but in my project we converted XL to binary and binary to XL. The XL is worked with data and attribute so Word should also work.

you can refer the below wiki

regards,

Harish

Former Member
0 Kudos

Hello Harish,

So without conversion agent or similar tools, it is not possible right?

When you worked with converting Binary to XL and vice versa, there was no requirement of displaying the data in normal XML tag. I think you would have just sent the binary data into these xml tags.

Regards

Krish

anupam_ghosh2
Active Contributor
0 Kudos

Hi AnandhaKrishnan,

                                     If you put binary data into xml there is 99.99% chance that the XML will become invalid. The binary files will contain characters not allowed in XML. The only way to prevent this is to stop the parser from interpreting the binary content. You can put the content in CDATA segment then parser will not interpret the same. From your post above I can make out that you need the content of the word document and not other attributes. In this case I would suggest to use a java mapping code to read only the content of word document and create a target xml out of it.

To read the content of the XML you can use Apache POI - the Java API for Microsoft Documents  .

Here is a reference to such a code

http://sanjaal.com/java/120/java-file/how-to-read-doc-file-using-java-and-apache-poi/

Regards

Anupam

Former Member
0 Kudos

Hi Anupam,

Thanks for the post. To give more detailed information.  I would need to lookup all documents stored in solution manager for a particular timing and send it through ABAP proxy and then to PI target structure.

My concern is that the documents might be a word/excel/pdf/ppts.

Someone else suggested that it will need to be converted first from binary to xstring and then being sent to PI.

Even if we filter for word and pdf documents only, extracting the content and displaying the content in an xml tag looks bit complicated.  Please throw in your recommendations.

Regards

Krish

anupam_ghosh2
Active Contributor
0 Kudos

Hi Krish,

                  It is not necessary to convert to xstring before sending the files to PI.

We can have a single java mapping code in PI server which reads file extension and process it accordingly. Thus we have java apache library to read word/excel/PDF files. You can embed the entire file content into CDATA segment and send it to PI server. PI interprets the CDATA segment according to filename extension and generates a target XML. Its not complicated to work with these files. I would suggest you to write simple codes to read these files. In case you face problems please come back to the forum.

Regards

Anupam

Former Member
0 Kudos

Hello Anupam,

Just to clarify, do you want me to send the converted binary file into ABAP proxy. How do we create CDATA type in xi. Am bit confused.

anupam_ghosh2
Active Contributor
0 Kudos

Hi Krish,

                you can directly read the files from Solman server using sender FTP adapter. Thus there will be no need of abap. In such case putting the file content into CDATA segment is not necessary.

Then in PI server the file would come as a binary byte stream. Java mapping code would interpret the contents and create XML equivalent.

In case you want to do the same using ABAP proxy then you need abap code creating the XML and putting file contents into an XML CDATA segment.

Regards

Anupam

Former Member
0 Kudos

Hello Anupam,

Thanks!

I would defnitely need abap code since I need to look for documents based on given time in SOLMAN tables and then fetch those using some function modules.

Regards

Krish

Former Member
0 Kudos

Hi,

I was wondering whether this can be achieved in ABAP level itself. Believe there are many FM which can read word/pdf/ and populate the content in an internal table. I can simply pass the table data to XML and send it across?

Regards

Krish

Former Member
0 Kudos

You can, but your message will most probably become invalid due to forbidden binary characters. Either use CDATA or convert the file to Base64 first. The latter will enlarge the message significantly, though.

Regards,

Jörg

Answers (0)