Executing Multiple Mapping Programs


SAP PI Interview Questions and SAP PI Tutorials

SAP PI Interview Questions and SAP PI Tutorials

Executing Multiple Mapping Programs

Executing Multiple Mapping Programs

We know the feature of interface mapping which can execute multiple mapping programs consecutively. This blog talks about the execution of multiple mapping programs in interface mapping.

When you find the complexity in mapping, with help of this feature we can divide up the mapping into multiple mapping programs. Could be helpful for beginners.

Example:

AMR (Automated Meter Reading) to SAP-ISU (Industry Solution utilities).

AMR generates fixed length files in FTP server from there PI should pick the files and converts into BAPI calls.

AMR Fixed Length text file should be converted into BAPI XML.

Possible ways:

1. This can be done with java mapping without FCC.

2. With FCC can be done (Single message mapping)

3. Multiple Mapping programs (Java mapping and message mapping without FCC

Multiple mappings in one interface mapping:

There are two mapping programs are taken as mentioned below, these are executed in the order of top to bottom.

1.Java mapping which takes fixed length source files and generates source xml file (MT_AMR_Source).

2.Message mapping, it takes the source xml file (MT_AMR_Source) generated by Java mapping, as input, and generates BAPI xml file.

1. Java Mapping:

/**

 * @author PNemalikanti

 */

import java.io.BufferedReader;

import java.io.InputStream;

import java.io.InputStreamReader;

import java.io.OutputStream;

import java.util.Map;

import com.sap.aii.mapping.api.*;

public class AMR implements StreamTransformation

{

SAP PI Interview Questions and SAP PI Tutorials

SAP PI Interview Questions and SAP PI Tutorials

      private Map param;

            public void setParameter(Map param)

            {

                  this.param = param;

            }

      public void execute(InputStream in ,OutputStream out)

            {

              try

              {

                  out.write(“<?xml version =’1.0′ encoding=’UTF-8′?>”.getBytes());

                  out.write(“<ns0:MT_AMR_Source xmlns:ns0=\”http://amrprofiles.com\”>”.getBytes());

                  String inLine=null;

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

                  while((inLine = bin.readLine())!=null)

                  {

                    String profileNo=null;

                    String fromDate=null;

                    String fromTime=null;

                    String fromOffset=null;

                    String toDate=null;

                    String toTime=null;

                    String toOffset=null;

                    String profileVal=null;

                    String status=null;

                    String unit=null;

                    profileNo=inLine.substring(0,18);

                    fromDate=inLine.substring(19,27);

                    fromTime=inLine.substring(28,34);

                    fromOffset=inLine.substring(35,38);

                    toDate=inLine.substring(39,47);

                    toTime=inLine.substring(48,54);

                    toOffset=inLine.substring(55,58);

                    profileVal=inLine.substring(59,90);

                    status=inLine.substring(91,95);

                    unit=inLine.substring(96,99);

                    out.write(“<Profiles>”.getBytes());

                    out.write((“<Profile>”+profileNo+”</Profile>”).getBytes());

                    out.write((“<DateFrom>”+fromDate+”</DateFrom>”).getBytes());

                    out.write((“<TimeFrom>”+fromTime+”</TimeFrom>”).getBytes());

                    out.write((“<FromOffset>”+fromOffset+”</FromOffset>”).getBytes());

                    out.write((“<DateTo>”+toDate+”</DateTo>”).getBytes());

                    out.write((“<TimeTo>”+toTime+”</TimeTo>”).getBytes());

                    out.write((“<ToOffset>”+toOffset+”</ToOffset>”).getBytes());

                    out.write((“<Value>”+profileVal+”</Value>”).getBytes());

                    out.write((“<Status>”+status+”</Status>”).getBytes());

                    out.write((“<Unit>”+unit+”</Unit>”).getBytes());

                    out.write(“</Profiles>”.getBytes());

                  }

                    out.write(“</ns0:MT_AMR_Source>”.getBytes());

              }

              catch (Throwable e)

              {

              }

            }

}

Note: Java mapping gives input source xml file to message mapping.

2. Message Mapping:(Generates BAPI XML )

image

Interface Mapping:

Java Mapping and Message Mapping are registered here.

image

Source Fixed Length File:

image

BAPI XML:

image

With help of Executing multiple programs(Java Mapping and Message mapping) AMR Fixed length files are converted into BAPI_ISUPROFILE_IMPORT xml file.

SAP PI Interview Questions and SAP PI Tutorials

SAP PI Interview Questions and SAP PI Tutorials

Share this:
Share this page via Email Share this page via Stumble Upon Share this page via Digg this Share this page via Facebook Share this page via Twitter
www.pdf24.org    Send article as PDF   
This entry was posted in sap pi 7.1 tutorials. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *