Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
iprieto
Contributor
0 Kudos

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.

 

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:

 

 

 

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.

3 Comments