cancel
Showing results for 
Search instead for 
Did you mean: 

Map binary to function module base64

0 Kudos

Hi,

I searched a long time at SDN but didn't found something, that solved my Problem.

My scenario:

I'm getting an mail with a pdf attached. This pdf has to be mapped to a function module with a SOLIX structure (RAW255).

1. swap the payload (PayloadSwapBean)

2. convert the attachment (MessageTransformBean) with the following parameters:

Transform.Class com.sap.aii.messaging.adapter.Conversion

Transform.ContentType text/xml

xml.conversionType SimplePlain2XML

xml.documentName MT_pdf_binary

xml.documentNamespace http://dcx.com/mhp_mail

xml.fieldNames value

xml.fieldSeparator 'nl'

xml.processFieldNames fromConfiguration

xml.structureTitle line

3. the message type of the input data:

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_pdf_binary xmlns:ns0="http://xxx">

<line>

<value>aaaa</value>

</line>

<line>

<value>bbbb</value>

</line>

</ns0:MT_pdf_binary>

4. in the montior i can see the pdf line by line in the xml doc. the field "value" is type base64binary

5. i created a mapping, which maps line by line to the fm

6. when i execute (test and the mapping, i get the following result:

Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x10(:main:, row:49, col:14) com.sap.aii.utilxi.misc.api.BaseRuntimeException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x10(:main:, row:49, col:14)

<?xml version="1.0" encoding="utf-8"?>

<ns:MT_pdf_binary xmlns:ns="xxx">

<line>

<value>%PDF-1.5</value>

</line>

<line>

<value>% </value>

</line>

<line>

<value>1 0 obj</value>

</line>

<line>

<value>&lt;&lt;/Type/Catalog/Pages 2 0 R/Lang(de-DE) /StructTreeRoot 8 0 R/MarkInfo&lt;&lt;/Marked true&gt;&gt;&gt;&gt;</value>

</line>

<line>

<value>endobj</value>

</line>

<line>

<value>2 0 obj</value>

</line>

...

one example for a fm that use this typ of input structure is SX_OBJECT_RECEIVE in the CONTENTS_BIN table.

has anyone a idea what i have to change?

regards and thanks

jp

Accepted Solutions (1)

Accepted Solutions (1)

stefan_grube
Active Contributor
0 Kudos

Your PDF is not in base64 encoding.

It is plain PDF, nothing else. Therefore you cannot do a content conversion for this.

You have to do the whole stuff in a self written adapter module.

Transform the attachment to a format that the RFC adapter needs.

If you had a Web AS > 6.20 you could use an ABAP proxy instead the RFC and handle the attachment without change.

Regards

Stefan

0 Kudos

isn't it possible to convert the plain pdf to base64 (maybe with a adapter module)? then i coud map it to the SAP standard fm?

regrads

jp

0 Kudos

I found this blog from Felix Jeyareuben:

/people/sap.user72/blog/2005/07/15/copy-a-file-with-same-filename-using-xi

i could use this module to convert the pdf to base 64 and then pass it to den function module base64 field.

Regards

jp

stefan_grube
Active Contributor
0 Kudos

You can do the base64 conversion only with a self-written adapter module.

There is no standard for this.

Watch this weblog to get an idea how this could look like:

/people/sap.user72/blog/2005/07/15/copy-a-file-with-same-filename-using-xi

Regards

Stefan

Answers (1)

Answers (1)

bhavesh_kantilal
Active Contributor
0 Kudos

><i>com.sap.aii.utilxi.misc.api.BaseRuntimeException: Fatal Error: com.sap.engine.lib.xml.parser.ParserException: Invalid char #0x10(:main:, row:49, col:14)</i>

This error implies that the source data contains some characters that is not a valid XML chacrater.

Try opening this Source XML in an Browser like IE and check if all the charcters are displayed fine (normally non XML charcters are displayed as a square)

Regards

Bhavesh

0 Kudos

Hi Bhavesh,

thanks for the fast replay. the IE says, that it cannot display the file because of invalid characters.

I guess the problem the MessageTransformBean parameters. I tried diffrent content types (plain/xml binary/xml ...)

At help.sap.com are only examples for MessageTransformBean configuration.

Regards jp

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Exactly the point i was making.

The source XML is not a valid XML and so the mapping is erroring out.

You might consider wirting a Java Mapping before the graphical mapping that will search for all Non XML characters and replace them with some other value (blank maybe).

We encountered a simlar issue with file adapters when the source file had non XML and this is the solution we came to.

Regards

Bhavesh

0 Kudos

Hi,

but the source file is a pdf binary. if I replace chars with space, it's not a valiad pdf anymore. maybe we have to create a non graphical mapping?

bhavesh_kantilal
Active Contributor
0 Kudos

Jorg,

Do you mean to say that you have an attachment and this attachment contains XML data?

If yes, then yes you need to use someother mapping that will be able to read the data from your PDF file.

Look into this blog,

/people/sap.user72/blog/2005/07/31/xi-read-data-from-pdf-file-in-sender-adapter

Maybe there is sometoher way as well , am not sure as I have not done much work on sender mail adapter with attachments.

regards

bhavesh

Regards

Bhavesh

0 Kudos

Hi,

thanks for the replpy.

I don't want to change the pdf file. i just want to send the pdf to a sap system via rfc function module as a binary.

regards

jp

0 Kudos

Hi,

is there a way to set a content encoding for the attachment? the flag for the mail body doesn't work for the attachment (why?)

regrads

jp