Skip to Content

Problem: One name can have multiple credit cards (as Source) and I want to generate summary of customer (as in Target) as well as total summary of all customer as report in summary tag.

 

 

Message Mapping:Example of source and traget structure.

image

 

First mape source NAME to target CUSTOMERANME.

image

 

target CARDCOUNT mapped to source CREDITCARD including the standard function count. Also change the context to records of CREDITCARD.

image

 

target CARDTOTALPAYMENT mapped with source PAYMENT including  standard function sum.

 image

 

 

image 

 image

 

Target TOTAL CARD mapped to source CREDIT CARD node with count function.

 image

 

Target TOTAL PAYMENT mapped  with source PAYMENT including standard function sum.

image

 

 

image

 

And here the output:

image

To report this post you need to login first.

4 Comments

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

    1. Hello,

      Looks like you put together a blog based on the requirement you were working. There is very little explaination to the the design patern.

      To preserve the sanity of the blogs published, please take a little more effort in translating the content from a requirement to a pattern that the community can benefit from.

      –Naveen

      (0) 
  1. Sankar Choudhury

    Problem: One name can have multiple credit cards (as Source) and I want to generate summary of customer (as in Target) as well as total summary of all customer as report in summary tag.<br/><br/><br/><br/>Apart from Graphical Message mapping(discussed in the earlier blog)this problem can be solved using Java Mapping also.<br/><br/><br/>The code for java mapping(implementing SAX parser)as follows:<br/><br/><br/>import java.io.;<br/>import java.util.Map;<br/>import javax.xml.parsers.SAXParser;<br/>import javax.xml.parsers.SAXParserFactory;<br/>import org.xml.sax.Attributes;<br/>import org.xml.sax.SAXException;<br/>import org.xml.sax.helpers.DefaultHandler;<br/>import com.sap.aii.mapping.api.StreamTransformation;<br/><br/>/*”tcust“”tcard“”tsum”               tcust+;<br/>          }<br/>          if(“Creditcard”.equals(eName)) {<br/>               count;     tcard;<br/>          }<br/>          if(“Payment”.equals(eName)) {<br/>               i=1;<br/>          }<br/>     }<br/><br/>     public void endElement(String namespaceURI, String sName, // simple name<br/>     String qName // qualified name<br/>     ) throws SAXException {<br/>          String eName = sName;<br/>          if (“”.equals(eName))<br/>               eName = qName;<br/>          if(“name”.equals(eName)) {<br/>               try {<br/>                    Echo01.out.write(“</CustomerName>”.getBytes());<br/>               } catch (Exception e) {<br/>                    e.printStackTrace();<br/>               }<br/>          }<br/>          if (“records”.equals(eName)) {<br/>               try {<br/>                    Echo01.out.write((“<CardCount>”count“</CardCount>”).getBytes());<br/>                    Echo01.out.write((“<CardTotalPayment>”sum“</CardTotalPayment></records>”).getBytes());<br/>               } catch (Exception e) {<br/>                    e.printStackTrace();<br/>               }<br/>               count=0;     sum=0;<br/>          }<br/>     }<br/><br/>     public void characters(char buf[], int offset, int len)<br/>          throws SAXException {<br/>          String s = new String(buf, offset, len);<br/>          if(i==1) {<br/>               sum=Integer.parseInt(s);     tsum+=Integer.parseInt(s);     i=0;<br/>          }<br/>          if(j==1) {<br/>               try {<br/>                    Echo01.out.write(s.trim().getBytes());<br/>               }<br/>               catch(IOException e) {<br/>                    e.printStackTrace();<br/>               }<br/>               j=0;<br/>          }<br/>     }<br/>     // Start a new line<br/>     private void nl() throws SAXException {<br/>          String lineEnd = System.getProperty(“line.separator”);<br/>          try {<br/>               Echo01.out.write(lineEnd.getBytes());<br/>          } catch (IOException e) {<br/>               throw new SAXException(“I/O error”, e);<br/>          }<br/>     }<br/>}<br/><br/><br/><br/>Regards:<br/>Sankar Choudhury

    (0) 
    1. sunil ojha Post author
      Thx dude,

      It’s really looking nice.

      It’s always easy to play with context and make easier the effort in consolidation or making the summary of the data. I just show this graphical technique to avoid the large code.

      Cheers,
      Sunil

      (0) 

Leave a Reply