Executing Multiple Mapping Programs

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

{

private Map param;

public void setParameter(Map param)

{

this.param = param;

}

public void execute(InputStream in ,OutputStream out)

{

try

{

out.write("".getBytes());

out.write("".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("".getBytes());

out.write((""+profileNo+"").getBytes());

out.write((""+fromDate+"").getBytes());

out.write((""+fromTime+"").getBytes());

out.write((""+fromOffset+"").getBytes());

out.write((""+toDate+"").getBytes());

out.write((""+toTime+"").getBytes());

out.write((""+toOffset+"").getBytes());

out.write((""+profileVal+"").getBytes());

out.write((""+status+"").getBytes());

out.write((""+unit+"").getBytes());

out.write("".getBytes());

}

out.write("".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 Developer Network SAP Weblogs: SAP Process Integration (PI)