cancel
Showing results for 
Search instead for 
Did you mean: 

Advise needed: Text + Binary content in one file using PI (B2B scenario)

Former Member
0 Kudos

Hello Friends,

My client wants to implement a new functionality which will create equipments in SAP and also upload the necessary equip diagrams(in pdf) into a content server. Proposal is to use PI to fetch data from vendor and then post it in sap and also upload the pdf to content server.

I am aware of how to handle basic xml/text file using file adapter to create idoc and post equipment in SAP, but I am not very clear how can we handle PDF/Binary data combined with standard XML/Text file in one go. Since the requirement is that PI receive both binary(scanned PDF file) along with mandatory data(readable text format) in same data object/file, I am confused.

I am looking for specific advise on following:

1> Is it possible to have an XML file which will have both text readable elements and also binary data in it.(So that Text readable data can be used to post EQUI transaction and binary will be used to post the pdf document on content server.

2 >If handling binary and text data is possible in one go, which adapter is capable of doing this and any blogs/advise.

3>If I get a pure binary format file, is it possible to convert it into BASE64 content in PI without calling any encoding FM's from R/3.

4> As of now I do not know what exact format will the sender send the file to PI, but its most likely in XML format(again not sure how binary and normal data will be contained in same file)...apologies in advance if it is possible to combine normal text and binary data in same xml file.

5> If it is not possible to combine both text and binary in one file, what as per your advise is the best approach to handle this scenario.

Appreciate your advise/guidance on above points.

Many thanks

Shirin

Accepted Solutions (1)

Accepted Solutions (1)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Shirin,

                 Here are the response to your questions

1> Is it possible to have an XML file which will have both text readable elements and also binary data in it.(So that Text readable data can be used to post EQUI transaction and binary will be used to post the pdf document on content server.

ans) you can of course have both data combined in XML file. The moment the file reaches the first message mapping you will get exception due to unreadable characters.

2 >If handling binary and text data is possible in one go, which adapter is capable of doing this and any blogs/advise.

ans) As you file is an XML , you do not need FCC. Use normal file adapter and let the XML flow to java mapping code. In the code you need to decode the binary part of the XML and convert it to UTF-8. Now you are not sure what kind of format the binary part will be in . If its base64 then there are blogs available else you need lot of trial and error.

3>If I get a pure binary format file, is it possible to convert it into BASE64 content in PI without calling any encoding FM's from R/3.

ans> here also use java mapping to do so Pls check this link http://www.wikihow.com/Encode-a-String-to-Base64-With-Java.

4> As of now I do not know what exact format will the sender send the file to PI, but its most likely in XML format(again not sure how binary and normal data will be contained in same file)...apologies in advance if it is possible to combine normal text and binary data in same xml file.

ans) Be it in any format , if the source file has binary content in it and you are sure about its encoding , use the same encoding scheme in communication channel. If you are not sure about encoding  then just mention the file type as binary in communication channel. In both of above cases avoid FCC and let the file content flow to integration engine. Alternatively you can use an adapter module in file adapter with same functions as that of java mapping.

5> If it is not possible to combine both text and binary in one file, what as per your advise is the best approach to handle this scenario.

ans> Its possible to combine any contents in xml. the problem is when you wasn't to read such file or parse it in PI then it has to be in proper encoding standards as UTF-8 etc. Thus if this file is input to your scenario then no problem go ahead with java mapping. In case this is going to be output from your scenario you need to ensure all parts of the file can be parsed by XML parser without errors.

Finally go through my article on binary file, which might help you take  a decision http://wiki.sdn.sap.com/wiki/x/SQxeDw

Regards

Anupam

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Shirin,

Please find my comments below:

1) I guess binary data will be coming as attachment..if yes then u can read the attachment in mapping (in PI7.1) using UDF or java mapping and then do base64 encoding and popluate that encoded data into one of the fileds in target paylaod. But in this case, ur receiver system has to read that encoded data, decode it and then upload the same to content server. Check with ABAP person.

2) You can design SOAP -> Proxy scenario

3) Yes, I remeber there is one wiki on the same published by Praveen please search on SDN for the same.

5) You can also think of passing the attachmnet as it is to receiver proxy system and then the proxy code will read the attachment and uypload the pdf file on content server

Thanks

Amit Srivastava

former_member181985
Active Contributor
0 Kudos

Hi Shirin,

I thing first you need to completely understand the file format of source system, then you/we can decide/provide the possible solutions. After that be clear on the interface flow in PI e.g., File --> PI -- (via ABAP proxy or RFC or IDOC etc..)--> SAP

XML can have normal data along with encrypt binary data (e.g., BASE64) in one file. you need to read the data either in module/mapping to separate binary data, decrypt and add them as attachments.

- Praveen

Former Member
0 Kudos

Hi Shirin,

I will advice you to get one sample file from the sender and get clear view of the requirement.

Please find my answers below:

1> Is it possible to have an XML file which will have both text readable elements and also binary data in it.(So that Text readable data can be used to post EQUI transaction and binary will be used to post the pdf document on content server.

Ans> It can be possible but not in same field. It may be two different fields will be there one will contain text value and another will be in binary.

2 >If handling binary and text data is possible in one go, which adapter is capable of doing this and any blogs/advise.

Ans> I think you have two receipent in your scenario. So you can have two different adapter depending on the communication type.

3>If I get a pure binary format file, is it possible to convert it into BASE64 content in PI without calling any encoding FM's from R/3.

Ans> Yes you can use BASE64ENCODER and BASE64DECODER method in PI.

4> As of now I do not know what exact format will the sender send the file to PI, but its most likely in XML format(again not sure how binary and normal data will be contained in same file)...apologies in advance if it is possible to combine normal text and binary data in same xml file.

Ans> Please get one sample file from sender.

5> If it is not possible to combine both text and binary in one file, what as per your advise is the best approach to handle this scenario.

Ans> Please refer to answer to question no 1.

Regards,

Nayan

Former Member
0 Kudos

Hi Shirin,

yes, it possible to convert it into BASE64 content in PI without calling any encoding FM's from R/3 , Use BASE64Encoder in mapping.

Pls look at the below threads ,it may help.

http://scn.sap.com/thread/1769297

http://scn.sap.com/thread/1737494

Also check the below

http://scn.sap.com/people/farooq.farooqui3/blog/2008/05/22/decode-base64-incoming-encoded-informatio...