cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping lookups - RFC API

Former Member
0 Kudos

Hi

I have cr8ed rfc lookup in UDF,and I want to parse this xml and use only the value I need

I read in the forum that there are 2 ways of doing it :

DOM and SAX

any1 knows good weblogs/threads which ellaborates on how or explain how it should b done ?

thx,Shai

Accepted Solutions (1)

Accepted Solutions (1)

moorthy
Active Contributor
0 Kudos

HI,

For Mapping Lookups~

/people/alessandro.guarneri/blog/2006/03/27/sap-xi-lookup-api-the-killer

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

Hope this helps,

Moorthy

Answers (2)

Answers (2)

Former Member
0 Kudos

Thx Abhy for your detailed answer

Former Member
0 Kudos

now I have 1 field in my mapping program which contains all the xml output of the RFC

( v.small sized - only a number returned )

so we can use DOM

now I need to write other UDF function which takes this xml and gives me only the number I need

any code suggestions ?

thx,shai

henrique_pinto
Active Contributor
0 Kudos

Shai,

you don't have to do it in another UDF.

You can use some parsing method in the same one.

If you want to use DOM, you'll also have to choose a parser, since DOM's specification doesn't specify a parser, just document and element handlers, so there are various implementations of parsers for DOM. I've used Xerces's DOMParser (org.apache.xerces.parsers.DOMParser) on Java Mappings with success (never tried on UDF, though) and it's very simple.

After you get the output stream from the rfc lookup, just use:

DOMParser parser = new DOMParser();

InputSource input = new InputSource(in);

parser.parse(input);

Document MyDoc = parser.getDocument();

to get the Document object. Then you can use regular DOM methods to get the value.

For example, with

String value = MyDoc.getDocumentElement().getFirstChild().getNodeValue();

you'd get the value of the first child of the root element.

Regards,

Henrique.

Former Member
0 Kudos

do I need to add something to the "imports" line?

if yes, where should I put the package in the XI ?

thx,shai

Former Member
0 Kudos

Hi Shai

You need to import the packages that contains the class you need to use. You also need to have the relevant jar files in you enviroment.

Are you using the developer studio?

Former Member
0 Kudos

Hi Shai,

This blog and article deals with calling your RFC from your JAVA MAPPING / User Defined Function.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/801376c6-0501...

/people/sravya.talanki2/blog/2005/12/21/use-this-crazy-piece-for-any-rfc-mapping-lookups

And now going to the next half of your question regarding SAX and DOM parsers....

The user defined functions that you write in your Graphical Mapping has nothing to do with Java Mapping.

In your Graphical Mapping, the parsing of source structure is handled interannly by XI.

But, when you go for an explicit mapping technique like Java Mapping, you have to parse the source XML structure, so that you can write the logic for your mapping.

Java Mapping will execute a method called Execute, that will take the source XML structure as the Input Stream and then, you have to parse the Input STream and to do this parsing, you use SAX or DOM parser.

DOM processor loads the entire XML into the memory and is processor intenseive, SAX does it element by element and so is not processor intensive.

If you are using SAX parser, there are 5 methods . They are:

1) Start of the document(startDocument)

2) start of the element(startElement)

3) end of the element(endElement)

4) end of the document(endDocument)

5) chars()

Also check with any java site about SAX events how it works etc.

Java Mapping

http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm

DOM parser API

http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html

On how to create XML docs with SAX and DOM go thruugh these links:

http://www.cafeconleche.org/books/xmljava/chapters/ch09.html

http://www.cafeconleche.org/books/xmljava/chapters/ch06.html

Also go through these Blogs....

/people/prasad.ulagappan2/blog/2005/06/08/sax-parser

/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i

/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii

/people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii

I hope this helps...

Regards,

Abhy