Thursday, 23 February 2017

SAP PI/PO: Java Program to read the content from input file to output file


The below java code is to copy the data from the input file and paste the same data to output file.

package dynamicfilename;

import java.io.InputStream;
import java.io.OutputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import com.sap.aii.mapping.api.AbstractTransformation;
import com.sap.aii.mapping.api.DynamicConfiguration;
import com.sap.aii.mapping.api.DynamicConfigurationKey;
import com.sap.aii.mapping.api.StreamTransformationConstants;
import com.sap.aii.mapping.api.StreamTransformationException;
import com.sap.aii.mapping.api.TransformationInput;
import com.sap.aii.mapping.api.TransformationOutput;
import com.sap.aii.mapping.value.api.*;

public class dynamicfile extends AbstractTransformation
{
 private static final String String = null;

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);
   outputstream.write(b);
  }
  catch (Exception exception)
  {
   getTrace().addDebugMessage(exception.getMessage());
   throw new StreamTransformationException(exception.toString());
  }
 }
}





No comments:

Post a Comment