cancel
Showing results for 
Search instead for 
Did you mean: 

ABAP and Java mapping

Former Member
0 Kudos

Wanted to confirm my understaing for ABAP and JAVA mapping.

Am I correct in my assumption that these mapping techniques can be used only if input and ouput is in XML format ?

So if XI is receiving a flat comma separated text/non-XML file or an IDOC for that matter and output is NOT in XML format, say again flat text file or IDOC, I cannot use above two techniques?

All the docs I have read suggest that 'Execute' method is called when XML file/data is received, paresed using DOM/SAX/JAXB (for Java mapping) or IXML lib (for ABAP mapping) and then create a output XML file.

-Thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

moorthy
Active Contributor
0 Kudos

Hi,

<i>Am I correct in my assumption that these mapping techniques can be used only if input and ouput is in XML format ?</i>

>>Parser will parse only XML documents. It should have xml document format.

<i>

So if XI is receiving a flat comma separated text/non-XML file or an IDOC for that matter and output is NOT in XML format, say again flat text file or IDOC, I cannot use above two techniques?</i>

>>You can use it. Mapping is used for tranforming the sourcr structure into Target structre with Business Rules. Now Adapter comes into picture.SO idea is, the corresponding adapters will read the nonXML structure and give it to XI as an XI understandable XML structre

Hope it helps,

Regards,

Moorthy

Former Member
0 Kudos

Thanks.

Do you have any blog or document which explains such mapping for a non-XML strycture/file?

All the docs/blogs I have seen for ABAP or Java mapping always had XML as source and target .

-Bob.

MichalKrawczyk
Active Contributor
0 Kudos

Hi Bob,

have a look at this weblog:

/people/r.eijpe/blog/2006/02/20/xml-dom-processing-in-abap-part-iiib150-xml-dom-within-sap-xi-abap-mapping

it shows posting a flat file with the use of abap mapping

Regards,

michal

Former Member
0 Kudos

Thanks Michal.

Plz do not get me wrong/misunderstand here..it is still using DOM parser as sender adapter is HTTP and it sends the flat file as an XML file which is then parsed to target XML file.

This is the text from the blog:

***

The Flow

Posting the flat file

The source system will post the flat file to XI using the HTTP plain adapter. Before posting, the used webpage will wrap the flat file into an XML file just by adding a root element. This root element is necessary, because the Plain HTTP adapter of XI accepts only XML.

stefan_grube
Active Contributor
0 Kudos

Hi Bob,

Here you have a code sample for deescaping. I have have written this code a couple of time ago. The incoming file can be any text format. It might be XML, but not necessarily.

The main method is not reqired, but good for testing.

Regards

Stefan


/*
 * Created on 28.09.2005
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package sample;

import  com.sap.aii.mapping.api.*;
import  java.io.*;
import  java.util.Map;

public class Deescaping implements StreamTransformation{



		public static void main (String[] args) {
			try {
				InputStream in = new FileInputStream(new File("in.xml"));
				OutputStream out = new FileOutputStream(new File("out.xml"));
				Deescaping change = new Deescaping();
				change.execute(in, out);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}


		public void setParameter (Map map) {
		}


		public void execute (InputStream in, OutputStream out)
			throws StreamTransformationException {
			try {
				int c;
				while ((c = in.read()) != -1) {
					if (c != '&') {
						out.write(c);
					} else {
						// ampersand
						String help = "&";
						boolean exit = false;
						// check the next 5 chars, if there is a ';'
						for (int i = 0; i < 5 && !exit; i++) {
							c = in.read();
							if (c == -1) {
								exit = true;
							} else {
								// another ampersand?
								if (c == '&') {
									out.write(help.getBytes());
									help = "&";
									i = 0; // check the next 5 chars
								} else {
									help = help + (char) c;
									if (c == ';') {
										exit = true;
									}
									if (help.equals("&amp;")) {
										help = "&";
									}
									if (help.equals("&lt;")) {
										help = "<";
									}
									if (help.equals("&gt;")) {
										help = ">";
									}
									if (help.equals("&quot;")) {
										help = """;
									}
									if (help.equals("&apos;")) {
										help = "'";
									}
								}
							}
						} // for
						out.write(help.getBytes());
					}
				} // while
				out.flush();
			} catch (Exception e) {
				throw new StreamTransformationException(e.getMessage(),e);
			}
		}

}

Answers (0)