cancel
Showing results for 
Search instead for 
Did you mean: 

How to Use Flat File As source in operation mapping?

Former Member
0 Kudos

Hi dont want to use an FCC. I have written an JAVA Mapping to convert a flat file to XML.

But in Interface Mapping How i can test this?

Accepted Solutions (0)

Answers (5)

Answers (5)

RaghuVamseedhar
Active Contributor
0 Kudos
/*This java mapping will give same output as input payload */
package com.mapping;
import java.io.InputStream;
import java.io.OutputStream;

import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;

public class Java_Mapping extends AbstractTransformation {
	public void transform(TransformationInput transformationInput,
			TransformationOutput transformationOutput)
			throws StreamTransformationException {
		try {
			InputStream inputstream = transformationInput.getInputPayload()
					.getInputStream();
			OutputStream outputstream = transformationOutput.getOutputPayload()
					.getOutputStream();

			byte[] b = new byte[inputstream.available()];
			inputstream.read(b);
			String strContent = new String(b);
			outputstream.write(strContent.getBytes());

		} catch (Exception exception) {
			exception.printStackTrace();
		}
	}
}

Edited by: Raghu Vamsee on Jan 5, 2011 3:46 PM

former_member189420
Active Participant
0 Kudos

Hello Raghu,

Thanks for clearing my misconception. I will have to work on it to understand better.

@Stefan,

I understand the original question did not mean "How to do Java mapping without XML as input?". However, considering the fact that forums are meant for discussion it is good to clear the misconceptions. Thanks for your input as well.

Thanks & Regards,

Anand Patil

Edited by: Anand Patil on Jan 6, 2011 10:09 PM

RaghuVamseedhar
Active Contributor
0 Kudos

Guysu2026 discussion is going in wrong direction.

It is misconception that Operational mapping can only take XML as input and give only XML as output.

Hi Debashish Roy,

Operation mapping can take any set of characters and give out any set of characters. You can even send flat files, XML files, photos, movie clips....

Note:

Graphical, XSLT mapping, DOM and SAX parser(SAX can give non XML as output) u2013 input and output are always XML.

Java, ABAP mapping u2013 input and output can be anything.

In operation mapping click on u201Csource text viewu201D icon and paste you test data (flat file) then click on test button.

Check out this by yourself,

Use below java mapping code and in operation mapping click on u201Csource text viewu201D icon and type u201Ctest data 123@u201D (this not XML) then click on test button. Output will be "test data 123@u201D. Now you can extend below java mapping according to your requirement.

Regards,

Raghu Vamsee

Edited by: Raghu Vamsee on Jan 6, 2011 1:51 PM

stefan_grube
Active Contributor
0 Kudos

Test your Java mapping with an external tool first:

/people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio

Java mapping does not require XML, only graphical mapping and XSLT require XML.

former_member189420
Active Participant
0 Kudos

Hey Stephan,

Do you have an example as how the Java Mapping is done without input in XML format, bypassing the adapter???

Thanks in advance.

Regards,

Anand Patil

stefan_grube
Active Contributor
0 Kudos

> Do you have an example as how the Java Mapping is done without input in XML format, bypassing the adapter???

No, I don't. But that was not the original question. I suppose Debashish Roy has already written any.

Former Member
0 Kudos

thanks Stefan

But external tool means ? i have already tested locally in eclipse.

I want to test in PI reporisotory. or in any other way without configuring the scenario.

Can you put some light on this?

former_member189420
Active Participant
0 Kudos

Hello,

When you do not want to use FCC and want to convert a non-xml format to XML then you will have to work at Adapter level and not at Java Mapping. Java mapping requires input in XML format and outputs in XML format.

If you are looking for something else then request you to reframe your question.

Regards,

Anand Patil

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Source file needs to be in xml format for testing. So you cannot test it in ESR/IR tool.