Skip to Content

While going through the SDN forum, I saw, some of us wanted to know how to generate a PDF file out of receiver file adapter in XI. While ideas from other SDN members include Java mapping or proxies, here we will see how to use the Module Processor to do the conversion job.

The advantage of using module processor exit is its flexibility to take variables in configuration, instead of hard coding as with mapping program or proxies

In the below example, we receive a simple XML file and transform it to XSL FO format using XSLT mapping. Then we use FOP (download source from Apache FOP ) for converting the XSL-FO to PDF format

Design

Target schema is available in the source FOP directory srcfoschema, which was downloaded from apache.org. But this needs to be tweaked to upload successfully in XI. You can download the tweaked version from FOP XSD

Configuration

On the receiver file adapter, we will use a module processor exit bean. The code snippet for the processor bean is provided below

This module references the following jar files fop.jar, avalon-framework-cvs-20020806.jar, batik.jar, xalan-2.4.1.jar, xercesImpl-2.2.1.jar and xml-apis.jar. These jar files are available in the build and lib directory of FOP download

That’s it. You are now ready to test your interface. Data transfer using PDF offers various benefits on security and data integrity. By using Java cryptology, you can also encrypt the PDF file and secure it with a password for additional security

In my next blog, I will talk about how to build a module for reading content from a PDF file, in the sender adapter

To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

  1. Great work and keep going. My favorite is iText, a free Java-PDF library ;). Eager to read your next blog 🙂
    Best regards,
    Felix
    (0) 
    1. Thanks Felix. The reason I chose Apache FOP is because I still thought IText has its own IText-XML format as against FOP which supports more standardized XSL-FO (correct me if I am wrong). No doubt, I hear from other resources that iText is much faster than FOP.
      KK
      (0) 
      1. srikumar venkatraman
        Hi,

        I am not sure if this is the right place to ask the doubt.

        Assuming a i convert a existing pdf file into xml format and pass that to function module in form of string. is it possible to recreate the pdf with same formatting structure in backend.

        i am creating pdf using itext and then reading the pdf and converting it into xml and then passing the xml file as string. The round about way is so since i am using it mobile infrastructure based scenario and i can only pass string to the r3. please let me know if the following is possible

        (0) 
        1. Krishnakumar Ramamoorthy Post author
          I don’t know what version of R/3 you are on but check if you could use XSTRING as the input parameter in a function module. In which case, you don’t need to convert the PDF content to XML (no adapter module required). You can just use the file adapter to read the PDF file and pass it to the integration server. For the interface description in XI, you will use a data of base64Binary. Then you can use java mapping to map the binary data to input parameter of your RFC. I would suggest ABAP proxy if your backend system has capabilities for doing ABAP proxies instead of RFC, in which case no mapping is required.

          If you cannot use XSTRING in your RFC, you can still convert the binary data to string (use proper encoding) in your java mapping . Once within RFC module you could standard function module SCMS_STRING_TO_XSTRING to convert the PDF string to XSTRING to get your PDF data.

          Hope this helps
          KK

          (0) 
  2. ganesh jonna
    >>ZIP the above XSLT, upload to XI and use the same in XSLT mapping….What do you mean by this? How to upload. Let me know. Thanks a lot.

    Regards
    Ganesh

    (0) 
  3. ganesh jonna
    Hi Ramamoorthy,
    Iam using NWDS as development env.
    I created a Java project and added the jars mentioned in the blog. But still am getting errors for Message and ModuleData process……the very first line. Also let me what should i give in IR,ID.

    Thanks a lot,
    regards,
    Ganesh

    (0) 
  4. Christopher Kühn
    Hello Ramamoorthy,

    I have a question regarding the configuration in Integration Directory. Which entries I have to make in the file receiver communication channel in the modul configuration?

    Have I to create an own module (with fop.jar etc.) and deploy it with JSPM (we have PI 7.11)?

    Thanks and best regards!
    Christopher Kühn

    (0) 

Leave a Reply