cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping complete input XML structure into one field on target

former_member203631
Participant
0 Kudos

Hi,

I have a scenario where I need to map the complete input XML structure as it is, into one field on target side. so can we achieve this in Graphical Mapping? If yes, please share your valuable info.

Regards,

Shiva.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello,

this is the java map code.just compile it and made a .zip file import it and use it Interface Mapping.

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 PayloadToXMLField1 implements StreamTransformation {

String strXML = new String();

//Declare the XML tag for your XML message

String StartXMLTag = "<DocumentBody>";

String EndXMLTag = "</DocumentBody>";

//String StartXMLTag1 = "<Code>";

//String EndXMLTag1 = "</Code>";

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");

}

String outputPayload =

StartXMLTag

+ "<![CDATA["

+ strXML

+ "]]>"

+ EndXMLTag;

try {

out.write(outputPayload.getBytes());

trace.addInfo("Process Completed");;

} catch (Exception e) {

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

}

}

}

Former Member
0 Kudos

Also while compiling u need the file aii_map_api.jar

Answers (3)

Answers (3)

former_member200962
Active Contributor
0 Kudos

your requirement can even be done using XSLT mapping:

Regards,

Abhishek.

former_member203631
Participant
0 Kudos

Hi all,

Thanks for your info. It will definetly helpful for me but actually I wanted to know whether we can achieve this task in GM. If yes. how?

Regards,

Shiva.

former_member200962
Active Contributor
0 Kudos

dont think we can achieve this in graphical mapping....and even if we can it wont be as simple as XSLT or JAVA

Shabarish_Nair
Active Contributor
0 Kudos

>

> Hi all,

>

> Thanks for your info. It will definetly helpful for me but actually I wanted to know whether we can achieve this task in GM. If yes. how?

>

>

> Regards,

> Shiva.

not possible via GM, the best bet is to go via the java way. its a simple code just ref the wiki post

Shabarish_Nair
Active Contributor
0 Kudos

https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/wholePayloadtoaXML+field

have a look into that wiki which will detail the required steps.

All you require is a very simple java mapping

Former Member
0 Kudos

Hi

Check below wiki

https://www.sdn.sap.com/irj/scn/wiki?path=/display/snippets/javaMapping-ConverttheInputxmltoString

Srini