cancel
Showing results for 
Search instead for 
Did you mean: 

UDF's and XSLT Mapping

Former Member
0 Kudos

Hi,

I am very much confused when to use UDF's and when to use XSLT etc. Please make me to understand with good examples.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi,

UDF's. In graphical mapping there are some standard functions.In most cases these standard functions are sufficient but sumtimes a scenario would require something more than a standard function.

For example :a count function in graphical mapping will count the number of records but suppose we need a count function to count records starting from suppose 02 then we will have to write a UDF.

XSLT MAPPING:XSLT is used for transforming xml documents into xhtml or other xml documents.

It is used along with xpath to define parts of the source

document that should match one or more predefined templates. When a match

is found, XSLT transforms matching part of the source document into result

document.

Thanks,

Sidhvin Mada

Former Member
0 Kudos

HI,

UDF's are user defined functions are of two types,simple UDF which takes in one input and gives out one output and the second one is advanced UDF where in u can access more than one fields,and the result is passed on to ResultList.

UDF can be used in graphical mapping depends upon the requirement.

1) If u wanted to do manuplication in data which can not be done by using the standared XI function that time we go for UDF.

2) For doing Lookup we write the code in UDF and pass the value to R3 system.

3) If u need to compare the input value and pass the other value based on comparision that time can go for UDF.

There are many different requirement for which we can go ahead with UDF.

What is XSLT:

XSLT stands for EXtensible Stylesheet Language Transformations. It is an XML based language for transforming XML documents into any other formats suitable for browser to display, on the basis of set of well-defined rules.

It can be used to transform

• XML to XML - From one XML data format to another

• XML to Text

• XML to HTML/XHTML

• XML to PDF

A few example cases in which an XSLT mapping can be used:-

 When the required output is other than XML like Text, Html or XHTML (html displayed as XML )

 When default namespace coming from graphical mapping is not required or is to be changed as per requirements.

 When data is to be filtered based on certain fields (considering File as source)

 When data is to be sorted based on certain field (considering File as source)

 When data is to be grouped based on certain field (considering File as source).

Advantages of using XSLT mapping

 XSLT program itself defines its own target structure.

 XSLT programs can be imported into SAP XI. Message mapping step can be avoided. One can directly go for interface mapping once message interfaces are created and mapping is imported.

 XSLT provides use of number of standard XPath functions that can replaces graphical mapping involving user defined java functions easily.

 File content conversion at receiver side can be avoided in case of text or html output.

 Multiple occurrences of node within tree (source XML) can be handled easily.

 XSLT can be used in combination with graphical mapping.

 Multi-mapping is also possible using xslt.

 XSLT can be used with ABAP and JAVA Extensions.

But at the same XSLT has the disadvantages also.

Thnx

Chirag

aashish_sinha
Active Contributor
0 Kudos

Hi,

XSLT Mapping :

Interface descriptions are in the form of XML documents. XSL Transformation (XSLT) is a member of the XML family of languages. It describes how an XML structure is transformed into another XML structure.

Features

XPath and <xsl:include>

You can define mappings using XSLT together with XPath. XPath is also a specification of the XML family. Using XPath you can address any node in an XML document. XSLT implements XPath expressions to select substructures of an XML document. Using templates in XSLT you can define the mapping rules for the selected substructures.

You can use the XSLT tags <xsl:include> and <xsl:import> to include predefined templates for substructures in a complete mapping definition. In this way, you can reuse mappings for data types.

Runtime Constants

In the same way as in Java mappings, the mapping runtime in XSLT programs also returns parameters that you can use to evaluate information in the XSLT program that is not known until runtime.

For XSLT Mapping refer, http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm

UDF :

If the standard functions for a target field mapping do not fulfill your requirements, or if the graphical representation becomes unclear due to the complexity of the mapping, you have the option of creating your own user-defined functions. You can create Java source text in this function. The function is included in the Java coding that is generated for the message mapping as a Java method.

Make sure you read the implementation considerations in Java Mapping, which also apply to user-defined functions in message mappings.

A user-defined function is only visible in the message mapping in which you created it. You can insert the function in the data-flow editor as a standard function by using the User-Defined function category.

For UDF refer, http://help.sap.com/saphelp_erp2004/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm

Implementation of UDF (Java Mapping)

Check if your system contains this jar aii_map_api.jar. This jar file is necessary for Java Mapping.

These are the steps to create a java mapping.

1. Develop your Java code locally e.g. with your IDE

2. Create a .jar or a .zip

2.1 Using the jar command of the jdk

2.2 Using a built-in IDE functionality

3. Create a new Imported Archive and import the .jar to the Integration Repository

Hope this will help you.

Regards

Aashish Sinha

PS : Reward points