cancel
Showing results for 
Search instead for 
Did you mean: 

Java Mapping

Former Member
0 Kudos

Hi all,

I have written a java mapping program which wil take the input value as CSV and convert that into XML of the target structure.

The structure is like

Source

<Root>

<Number>1</Number>

</Root>

<Root>

<Number>2</Number>

</Root>

<Root> <Number>3</Number>

</Root>

The Source is a CSV with delimiter as ";" source file 1;2;3

The Target Structure is

<Node>

<Value>1</Value>

<Value>2</Value>

<Value>3</Value>

</Node>

The program i have written is as follows:

public class TMapping implements StreamTransformation {

private Map map;

public void setParameter (Map param){

map = param;

}

public void execute(InputStream in, OutputStream out) throws StreamTransformationException {

try {

out.write("<?xml version ='1.0' encoding='UTF-8'?>".getBytes());

out.write("<ns0:MT_MappingTest_Target xmlns:ns0=\"http://www.infosys.com/sap/xi/projects/rt/n2\">".getBytes());

out.write("<Node>".getBytes());

String line = null;

BufferedReader bin = new BufferedReader(new InputStreamReader(in));

while((line = bin.readLine())!= null) {

String value = null;

char[] str = new char[100];

str = line.toCharArray();

int s1 = 0;

int s2 = 0;

String[] Data = new String[10];

for(int i=0;i<line.length();i++)

{

if(str<i>==';')

{

Data[s1] = line.substring(s2,i);

s1=s1+1;

s2=i+1;

}

if(i== line.length()-1)

{

Data[s1] = line.substring(s2,i+1);

for(int j=0; j<3; j++) {

String data = Data[j];

out.write(("<Value>"data"</Value>").getBytes());

}

}

}

}

out.write("</Node>".getBytes());

out.write("</ns0:MT_MappingTest_Target>".getBytes());

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

}

I have excluded the imports:

I tried it using the main method and it gives a perfect out.xml file

i imported the same into XI and the error which is its showing is

"does not implement the required interface com.sap.aii.mapping.api.StreamTransformation"

when i have implemented the StreamTransformation interface

Can any one tell me how to implement the same

Rgds

Aditya

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Ref Michal FAQ Blog:

/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions

Where can I find aii_map_api.jar to create my Java mapping?

Thanks

Answers (2)

Answers (2)

Former Member
0 Kudos

Thnks

I have figured out the problem

actually it does not matter the target structure.

I wil get an error in interface mapping but wil work in end to end

Rgds

Aditya

henrique_pinto
Active Contributor
0 Kudos

error? No, you don't have to "have error anyway".

Why's that?

Regards,

Henrique.

Former Member
0 Kudos

Thnks

i sorted out the issue can i knw one more thng

wht should i do when i have a Native SQL String in JDBC adpters.

i mean wht should be the target structure kind of i knw tht i need to make a statement which gives INSERT .......

i need to use a jave mapping

but how do u make a Interface mapping when i dnt have a data type

For an eg

i have a source structure as

<Node>

<Name>Aditya</Name>

<City>Mumbai</City>

</Node>

and the target should be INSERT into empl values (Aditya,Mumbai)

wht should be the structure.

for the message type at the target

Rgds

Aditya

henrique_pinto
Active Contributor
0 Kudos

Hey aditya,

the receiver interface depends on the keys and on what kind of statement you want to query.

Check this documentation on receiver JDBC interface:

http://help.sap.com/saphelp_nw2004s/helpdata/en/2e/96fd3f2d14e869e10000000a155106/frameset.htm

Regards,

Henrique.