cancel
Showing results for 
Search instead for 
Did you mean: 

how to map n x m to i

former_member186158
Active Participant
0 Kudos

how to map all the items to another node (0...unbounded)?

head (0...unbounded)

-- t1

--t2

--t2

-- item (0....unbounded)

-


i1

-


i2

-


i3

Edited by: Shen Peng on Dec 7, 2010 9:28 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Shen,

I am not clear about your requirement. Please tell the sender structure and the receiver structure with your exact requirement.

Thanks,

former_member186158
Active Participant
0 Kudos

<records> (0...unbounded)

<t2>(0,1)

<custcd/>

<compcd/>

<createdate/>

<sumitems/>

<remark1/>

<remark2/>

</t2>

<t3> (0...unbounded)

<t3>

<store_bill_dtl_id/>

<store_bill_id/>

<brand_code/>

<brand_name/>

<quantity/>

<is_import/>

</t3>

</records>

map to

<st1> (0,unbounded)

<DML action="SQL_DML">

<access/> (0,1)

<key><store_bill_dtl_id></store_bill_dtl_id>

<store_bill_id></store_bill_id>

<brand_code></brand_code>

<brand_name></brand_name>

<quantity></quantity>

<is_import></is_import>

</key>

.....

That's node t3 to st1.

Thanks for your quickly reply.

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

If you are using PI 7.1 and above, just right-click t3 and then click Return as XML and then map it to <key>. Otherwise you have to make use Java Mapping to fullfil your requirement. Refer to the following wiki below:

http://wiki.sdn.sap.com/wiki/display/XI/WholePayloadtoaXML+field

Hope this helps,

Mark

Former Member
0 Kudos

Hi Shen,

If the version of your PI system is less than 7.1, then you need to go for Java mapping to achieve this requirement.

Here is a smple Java mapping code.

import com.sap.aii.mapping.api.StreamTransformation;

import com.sap.aii.mapping.api.AbstractTrace;

import com.sap.aii.mapping.api.StreamTransformationConstants;

import java.util.Map;

import java.io.*;

public class PayloadToXMLField implements StreamTransformation {

String strXML = new String();

//Declare the XML tag for your XML message

String StartXMLTag = "<Payload>";

String EndXMLTag = "</Payload>";

AbstractTrace trace;

private Map param = null;

public void setParameter(Map param) {

this.param = param;

}

public void execute(InputStream in, OutputStream out) {

trace =

(AbstractTrace) param.get(

StreamTransformationConstants.MAPPING_TRACE);

trace.addInfo("Process Started");

try {

StringBuffer strbuffer = new StringBuffer();

byte[] b = new byte[4096];

for (int n;(n = in.read(b)) != -1;) {

strbuffer.append(new String(b, 0, n));

}

strXML = strbuffer.toString();

} catch (Exception e) {

System.out.println("Exception Occurred");

}

outputPayload =

"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"

+ StartXMLTag

+ strXML

+ EndXMLTag;

try {

out.write(outputPayload.getBytes());

trace.addInfo("Process Completed");;

} catch (Exception e) {

trace.addInfo("Process Terminated: Error in writing out payload");;

}

}

}

If you have PI 7.1, then refer the below link:

/people/jyothi.anagani/blog/2010/06/17/convert-the-input-xml-to-string-in-pi-71-using-standard-graphical-mapping

Thanks,