Skip to Content

In my company we have been working in a scenario where there was the requirement to create global variables in an interface mapping object.

The goal of this scenario was to send invoices via mail.

The scenario starts when a SAP R3 system sending and IDOC message to SAP PI. Once the IDOC message has been received by SAP PI, it must to be process by means of several mappings programs.

To summarize the mapping programs:

  1. M1:      Transform the IDOC XML message to XML IATA structure.
  2. M2: The      XML IATA structure had to be encoding to Base64 format.
  3. M3: Create      a MIME multipart message format for sending an e-mail with attachments.

The problem was that the IDOC structure contains the e-mail parameters. We should to use these values in the last mapping program and the reference of these data were losing in the sequential mapping process in runtime.

The operation mapping has the next structure:

    * M1: Convert IDOC to XML using a Graphical Mapping program.
    * M2: Encoding XML to Base64 format by means of Java Mapping.
    * M3: Build a Mime Multipart Object using of Graphical Mapping program.

We had searched a solution for this issue in the SDN but anything resolved this problem.
Thinking a solution, we made a Function Library where we have created some static attributes into the library.

image

 

In this library there is a method for store the values in the corresponding attributes.

Once done, the next step was the mapping programs creation. In our case, we made three mapping programs:

 

 image

 

The first mapping program (M1) is a graphical mapping that transforms a XML IDOC structure to XML IATA schema (it’s a standard schema for airline industry). In this mapping we loaded the attributes values in the global variables created in the library.

Then, we transformed the payload to BASE64 format (M2). The content of this Base64 will be use for attaching it in the mail message.

The last step was fulfils the Email XML structure to conform the email message. You can download from:  https://service.sap.com /~sapidb/012006153200000361852004E/ximail30_xsd.txt

In this step we needed the use of the static variables value, for do it, we had created some method for data manipulation. It is named getter and setter methods in Java terminology.

There is an important trick that you must to know, this solution only works in runtime and test option in design time doesn’t work.

Note: Maybe, in case of some messages will be process at the same time the solution may fail if you don’t make a solution for synchronized the static variables.

To report this post you need to login first.

3 Comments

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

  1. Sudharshan Aravamudan
    Hi Carlos,

    Nice and helpful blog.

    You can accomplish this by using Dynamic Cofiguration as well.
    1) Create your own user defined Dynamic Configuration fields and set the values in 1st step of Mapping.
    2) Get/Query the fields using Dynamic Configuration API in subsequent steps.

    Dynamic Configuration is acccesible from all types of mapping.

    Thanks.

    Best Regards,
    Sudharshan N A

    (0) 
  2. Divyakumar Jain
    Thanks for posting a weblog on PI.

    I am not much aware of variables in PI message mapping but as far as I know static variable in Java those are shared by all the instances of that class.

    So was curious to know if we have two IDocs delivered to PI at same time then is there a risk that wrong values will be picked by last mapping.

    Also we may consider using Container and Global Container for storing values which might be safe. Following is the link which talks about these Container.

    http://help.sap.com/saphelp_erp2004/helpdata/en/75/8e0f8f3b0c2e4ea5f8d8f9faa9461a/frameset.htm

    (0) 

Leave a Reply