Blog Archive

Thursday, June 21, 2018

java mapping reference links for SAP PI


csv to xml file and binary files dealing
xml format correction

Reference2 code java mapping code

public class MyJavaMapping extends AbstractTransformation {

  DynamicConfiguration conf; // used for dynamic configuration 
                             // (adapter-specific message attributes) 
  InputParameters param;     // used for input parameters

  // the method "transform" is called by Java Mapping Runtime
  public void transform (TransformationInput arg0, TransformationOutput arg1)  
                        throws StreamTransformationException {

    conf = arg0.getDynamicConfiguration(); // provide dynamic configuration 
    param = arg0.getInputParameters();     // provide input parameters


  // the method "execute" is called by "transform" and "main"
  public void execute (InputStream in, OutputStream out)  
                      throws StreamTransformationException {

    // Add your code here


  // reading dynamic values
  String getDynamicValue(String namespace, String name){

    if (conf == null) // in test mode, dynamic parameters cannot be used. 
      return "";      // Use default values instead
    DynamicConfigurationKey key = 
                 DynamicConfigurationKey.create(namespace, name);
    return conf.get(key);

  // reading input parameters
  String getInputParameter(String name){

    if (param == null){  // in test mode, input parameters cannot be used. 
      return "";         // Use default values instead
    } else {
      return (String) param.getValue(name);

  // the method "main" is using files for input and output
  public static void main(String[] args) {

    try {
      InputStream in = new FileInputStream(new File("in.xml"));
      OutputStream out = new FileOutputStream(new File("out.xml"));
      MyJavaMapping myMapping = new MyJavaMapping();
      myMapping.execute(in, out);
    } catch (Exception e) {

youtube link

No comments:

Post a Comment