User-defined function in message mappings
Hi experts,
I'm a senior c++ programmer, but I never write program by abap/java.
I want to create a user-defined function for mapping. Who can give me some instruction?
Many thanks.
SDN can. A simple search on SDN could provide you the steps and code as well. Try a search and come up with more specific doubts. I am sure most of the doubts would be gone.
Regards,
Prateek
Similar Messages
-
Defing user defined function in message mapping
hi experts of xi.
i want to create UDF for counting no of records in body and checking with trailer countinfo and adding all contract account amounts in file body and checking with trailer sum.
if these 2 comparings r not matched then we have to set flag field 'N' else we have to set as Y'.
waiting for ur answer.
regards.
seeta ram.Hi,
pretty easy if you want to count number of lines (records)
two inputs (trailer and line segment)
and you can just compare it inside
then you can just return Y or N
Regards,
michal
<a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions"><b>XI / PI FAQ - Frequently Asked Questions</b></a> -
Message Mapping (user-defined function)
Hi all,
Is there anyway to determine the XML message ID using an user-defined function in Message Mapping? When I go to SXI_MONITOR I see that all messages have an unique ID, but I'm having some difficulties to understand if there is any way to get that ID in a message mapping and pass it to a target structure? I see that it is possible to use constants like "Sender" and "Receiver", but I haven't found anything for the message ID.
Can you please help me?
Thanks in advance.
Regards,
Ricardo InácioTry this code..
Create an UDF and do not pass any arguments to it..
java.util.Map map;
// get runtime constant map
map = container.getTransformationParameters();
// get value of header field by using variable key
String msgid = (String) map.get(StreamTransformationConstants.MESSAGE_ID);
return msgid;
Now map this udf to your target field. Now test it....
P.s. Since message id is run time property therefore in mapping test tab it will not work. Try it at runtime.
Regards,
Sarvesh -
Need user define function for the message mapping structure
Hi All
I am new to XI.I need the java code for Udf for the following structure.
i have two input and one out put as error.
order_nos----
user define function-------error message
order_details----
num of orders---- i.e. 10
order_details------ i.e. whole order records details
1.i have to compare the 1st input with 2nd one means if the ist input contain 10 means there are 10 orders in 2nd input.if not then i have to give error message .
2.then i have to check the fields in 2nd input has no null values.if no values the output will be error message.
Edited by: Rohit Kumar on Dec 18, 2008 4:43 PMHi Sudhir
thanks for your continues help.i need some help so that i can fulfill my requirmrnt
this is my message mapping xml.
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:methodCall_MT xmlns:ns0="http://www.dfdsf">
<num_orders>10</num_orders>
<test_mode />
- <order_x> ( which is order details)
<order_id>t78tyu8t</order_id>
<order_date />
<mfg_id />
<catalog_id />
<first_name />
<last_name />
<recipient />
<message />
<address1 />
<address2 />
<address3 />
<city />
<state />
<zip />
<country />
<country_code />
<phone />
<subtotal />
<tax />
<shipping />
<total />
<shopatron_total />
<fulfiller_total />
<shipment_id />
- <additional_info>
<in_store_pickup />
- <express_shipping>
<express_shipping_flag />
<express_shipping_text />
<express_shipping_arrival />
</express_shipping>
</additional_info>
- <discount>
<discount_description />
<discount_percentage />
<discount_total />
</discount>
<lang_id />
<currency_id />
<packing_list />
<num_items />
- <items>
<item_id />
<quantity />
<price />
<part_number />
<fulfiller_total />
<shopatron_total />
- <options>
<option_x />
</options>
</items>
</order_x>
</ns0:methodCall_MT>
this my mapping where under one element number elements are there.when i am excuting the code to check the null value its always giving the there is null val but i have filled evrything.its due to first its checking the order_x and which will be always null.uder this all data will be filled.please suggest what to change in the udf.the code given by u is working fine but its failing in this scenario because it getting the parent filed is null. -
User - defined functions for calculating the taxes of state and country
hi expects,
how can write user-defined function in message mapping in which i want to calculate the states taxes (2500) and country taxes (5000) and give the result as grand total in output.please help me?Hi,
Activities
1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
graphic is explained in the accompanying text), which is located on the lower left-hand side of the
screen. In the menu, choose Simple Function or Advanced Function.
2. In the window that appears, specify the attributes of the new function:
Name
Technical name of the function. The name is displayed in the function chooser and on the data-flow
object.
Description
Description of how the function is used.
Cache
Function type (see above)
Argument Count
In this table, you specify the number of input values the function can process, and name them. All
functions are of type String.
3. In the window that appears, you can create Java source code:
a. You can import Java packages to your methods from the Imports input field, by specifying them
separated by a comma or semi-colon:
You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
all message mappings require these packages and therefore import them. You should be able to
access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
package under Import. In other words, you do not have to import it as an archive into the Integration
Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
In addition to the standard packages, you can also specify Java packages that you have imported as
archives and that are located in the same, or in an underlying software component version as the
message mapping.
b. Create your Java source text in the editor window or copy source text from another editor.
4. Confirm with Save and Close.
5. User-defined functions are limited to the message mapping in which you created the function. To
save the new function, save the message mapping.
6. To test the function, use the test environment.
The new function is now visible in the User-Defined function category. When you select this category,
a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
function to the data-flow editor, choose the arrow next to the button and select from the list box
displayed.
Regards
Seshagiri -
Acces to XI R/3 table into user-defined function. Is possible?
Hi experts.
We want to do a user defined function in message mapping that reads a value in R/3 table. R/3 table is created in XI r/3.
It´s possible?. How i can do it?.
Thanks for all.HI Julian
For your scenario, u need to create an rfc in the R/3 system and call that RFC from a user-defined function in XI by using the RFC Lookup facility..
Check out this following code...
com.sap.mw.jco.*;
public String Get_Customerl(String a,String b,Container container){
//write your code here
JCO.Repository mRepository;
// Change the logon information to your own system/user
JCO.Client mConnection = JCO.createClient(
"300", // SAP client
"XYZ" , // userid
"XYZ", // password
"EN", // language
"66.248.225.116", // host name
"00" ); // system number
// connect to SAP
mConnection.connect();
// create repository
mRepository = new JCO.Repository( "SAPLookup", mConnection );
// Create function
JCO.Function function = null;
IFunctionTemplate ft = mRepository.getFunctionTemplate("ZGET_MATERIAL");
function = ft.getFunction();
// Obtain parameter list for function
JCO.ParameterList input = function.getImportParameterList();
// Pass function parameters
input.setValue( a , "CUSTOMER" );
input.setValue( b , "NAME" );
mConnection.execute( function );
String ret = function.getExportParameterList().getString( "CUST");
mConnection.disconnect();
return ret;
This takes the customer number and name as input and the rfc maps these values in the table and returns the customer number if it exists in the database...
Hope u find it useful
Regards,
Hari -
Hi all,
I need to add 3 nodes in an user-defined function in message mapping using java code.The nodes r like EmpFirstName,EmpMiddleName,EmpLastName.I am writing one user-defined function like "ADD".How can i call these field names into "ADD" Function.
Thanks,
Gopi.Hi,
If you want to add the nodes to the input , then just add import parameters to the UDF.
If you want to create the multiple diff target nodes along with the values , then this would not be possible using an UDF.
it is possible to pass multiple values out of your UDF by writing an Advanced UDF , but, it would not be poissible to create multiple target nodes using an UDF.
Regards,
Bhavesh -
User defined function in java for message mapping
I wrote the following user defined function in java for message mapping and mapped vendor with this. The aim of this function is to write a error file at defined path when i send empty Vendor value from File to RFC-Function module BAPI_PO_CREATE. The "err.txt" error file is not written when i execute in TEST but the value "ERROR" is returned to destination Vendor Field.
public String validation(String a, Container container) {
//write your code here
if (a.equals("")) {
try {
String source = "Vendor cannot be empty";
char buffer[] = new char[source.length()];
source.getChars(0, source.length(), buffer, 0);
for (int i = 0; i < buffer.length; i +=2)
f0.write(buffer<i>);
f0.close();
FileWriter f1 = new FileWriter("/10.10.0.55/sapmnt/trans/edixiin/err.txt");
f1.write(buffer);
f1.close();
catch (IOException e) {}
return "ERROR";Hi Senthil,
Check these things :
1) Whether you have permission to create a file in that directory.
2) try giving this
10.10.0.55
sapmnt
trans
edixiin
err.txt
3) Also check for permissions.
Hope this will help you.
Regards
Suraj -
Alert messages by using any User Defined Functions
Hi friends,
I have one requirement.. that when ever my scenario successully processed.. (file to file scenario) i need to raise a ALERT message that is.. Successfully processed.. otherwise.. it should raise a Errors occured during Scenario.. These messages i want to display for my scenario..
for this requirement what can i do.. my scenario is with out BPMs, so, can u explain with clear steps.. is there any USER DEFINED FUNCTION IS REQUIRED OR with that UDF 's also can we do.. and where can we do other settings..
Thanks
BabuHi,
Check this blog.
/people/bhavesh.kantilal/blog/2006/07/25/triggering-xi-alerts-from-a-user-defined-function
Regards,
Sudheer. -
Error in simple user defined function
Hi all,
I have seen one simple user defined function on scenario. Now it is working fine. Same code I have used another place. But it is giving some errors
D:/usr/sap/C08/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapc6fa0c70297511dbaf7e00c09f4504e7/source/com/sap/xi/tf/_ST_MM_.java:3: package javax.mail.internet does not exist
import com.sap.aii.mappingtool.tf3.;import com.sap.aii.mappingtool.tf3.rt.;import java.util.;import java.io.; import java.lang.reflect.;import javax.mail.internet.;import javax.mail.;import java.util.;import java.util.Date;import javax.activation.;import java.lang.reflect.;import javax.mail.event.*;
Like that it has shown 13 errors. I have given the package names in imports field what previous function has.Hi,
Please see this from SAP help
<i>a. You can import Java packages to your methods from the Imports input field, by specifying them separated by a comma or semi-colon:
You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since all message mappings require these packages and therefore import them. You should be able to access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the package under Import. In other words, you do not have to import it as an archive into the Integration Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
In addition to the standard packages, you can also specify Java packages that you have imported as archives and that are located in the same, or in an underlying software component version as the message mapping.
b. Create your Java source text in the editor window or copy source text from another editor.</i>
http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
Regards
Vijaya -
Error Using imported .JAR in user-defined function
Hi All,
I am trying to use jar files provided to me in user defined function as follows:
DataEncryption temp = new DataEncryption();
String ret = new String();
ret = temp.getEncryptedData(a);
return ret;
All jar files working perfectly in java software, But when i am trying to test the mappings by using above user-defined function.
I am catching the error and put in target field then, I am getting following message in target field:
"An error occured in getEncryptedData method : java.lang.SecurityException: The provider SunJCE may not be signed by a trusted party"
Please help in finding the error.
RegardsRohan
Check if the XI Server JRE is the same as the client machine on which you have compiled your JAR.
1.4 has had this issue and i remember seeing it in a few forums.The problem should not occure in 1.5 -
hi,
i am using UDF(user defined functions) in my mapping.i defined the function in my mapping,but i want to use the same function in my other mappings.
here it is not visible in the new message mapping. i need o re-define same function for every nw mapping?
is there any other way ?hi,
you can do this in SAP XI 7.1 latest version.there is facility to make the UDF as global function by putting it into global library.
then the same UDF can use in any Mapping that u define in future
but this facility is not there in lower versions of XI -
User define function-remove leading zeros
Hi All,
i want java coding for mapping function rule "remove leading zeros" early.
kindly give me response as early as possible.
regards
PeeraHi Mahaboob
Write UDF to parse data .
String dataVal="0230";
int parseVal = Integer.parseInt(dataVal);
System.out.println("parseVal is "+parseVal);
result.addValue(parseVal); or return parseVal;
Have a look at this thread...
Re: User-defined function in multiple Message Mappings
http://help.sap.com/saphelp_erp2005/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
http://help.sap.com/saphelp_erp2005/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm
Thanks !!! -
Need help with user defined function
Hello SDN,
I need some help with a user-defined function. My source message contains multiple
generic records (1000 char string), and my target message is 1 header record,
then multiple generic records. See description of source and target messages below:
Source:
GenericRecordTable 1..unbounded
Row (1000 char string)
Target:
Field1 (char5)
Field2 (char5)
Field3 (char5)
IT_Data
GenericRecordTable 1..unbounded
Row (1000 char string)
Basically, what I need to do in my user defined funtion is to map the first record
in my source record to the 3 header fields, then map all of the rest of the records
(starting from line 2) into the GenericRecordTable.
Can someone please help me with the code for the user defined function(s) for this
mapping?
Thank you.hi,
Activities
1. To create a new user-defined function, in the data-flow editor, choose Create New Function (This
graphic is explained in the accompanying text), which is located on the lower left-hand side of the
screen. In the menu, choose Simple Function or Advanced Function.
2. In the window that appears, specify the attributes of the new function:
Name
Technical name of the function. The name is displayed in the function chooser and on the data-flow
object.
Description
Description of how the function is used.
Cache
Function type (see above)
Argument Count
In this table, you specify the number of input values the function can process, and name them. All
functions are of type String.
3. In the window that appears, you can create Java source code:
a. You can import Java packages to your methods from the Imports input field, by specifying them
separated by a comma or semi-colon:
You do not need to import the packages java.lang., java.util., java.io., and java.lang.reflect. since
all message mappings require these packages and therefore import them. You should be able to
access standard JDK and J2EE packages of the SAP Web Application Server by simply specifying the
package under Import. In other words, you do not have to import it as an archive into the Integration
Repository. You can also access classes of the SAP XML Toolkit, the SAP Java Connector, and the
SAP Logging Service (see also: Runtime Environment (Java-Mappings)).
In addition to the standard packages, you can also specify Java packages that you have imported as
archives and that are located in the same, or in an underlying software component version as the
message mapping.
b. Create your Java source text in the editor window or copy source text from another editor.
4. Confirm with Save and Close.
5. User-defined functions are limited to the message mapping in which you created the function. To
save the new function, save the message mapping.
6. To test the function, use the test environment.
The new function is now visible in the User-Defined function category. When you select this category,
a corresponding button is displayed in the function chooser pushbutton bar. To edit, delete, or add the
function to the data-flow editor, choose the arrow next to the button and select from the list box
displayed.
http://help.sap.com/saphelp_nw04/helpdata/en/d9/718e40496f6f1de10000000a1550b0/content.htm
http://java.sun.com/j2se/1.5.0/docs/api/
/people/krishna.moorthyp/blog/2006/07/29/documentation-html-editor-in-xi
/people/sap.user72/blog/2006/02/06/xi-mapping-tool-exports
http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
UDF -
http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/content.htm
Regards -
Error in conditional map using User Defined Function
All,
In my mapping I basically have a user defined function that returns the filename of my inbound file from the adapter-specific message attributes (file adapter). I know this is coded properly because if I simply assign this function to my destination field I can see the filename in the payload XML.
However if I conditionally check that returned value using if,then,else I get an error message stating:
"During the application mapping com/sap/xi/tf/_MaterialData2ZcustProdMastMulti_ a com.sap.aii.utilxi.misc.api.BaseRuntimeException was thrown: RuntimeException in Message-Mapping transformation"
Essentially in my if I'm checking if the value returned by my user defined function is equal to the constant "SOMECONSTANT" then I'm setting my destination field to some other constant value. Otherwise it's equal to a different constant value.
Any thoughts?Claus,
Thanks for the help. I actually had figured the problem out on my own. Sorry for not updating the thread sooner. What happened was this (as I suspected it wasn't related to my user defined function). For the newbies out there (of which I'm one) the problem was I was comparing strings in the graphical mapping tool using the Boolean "EQUALS" rather than the Text "EQUALSS".
Can you give yourself points for solving
Maybe you are looking for
-
HT204406 I am experiencing a very SLOW response on my iPhone when trying to make a play list.
I am at home with a very fast internet access and still it hangs up for about 30 seconds per song when trying to add them to my playlist. Why is that?
-
Transferring data from one external drive to another
HI, I want to get a new external hard drive and transfer all of the data from my old one - which is not full, but has started to click and operate slowly. The old external hard drive is where I keep the music files for my itunes library, as well as a
-
External Send Billing Document - Issues Generating Body Text in Email
Have generated output type to email billing document as PDF to customer. I am using medium 5 for 'External Send' and have everything working well - the subject line is correctly showing the company name and invoice number, also the PDF is tagged corr
-
Where to configure database schema detail in Oracle forms?
Hi, i'm new to Oracle Application Server. Our version is 9.0.4. I have been searching on and no idea which file that stored the reference to the external customer database schema (not the infra repository database) that will be used in a form. Is it
-
Your Music on Your BlackBerry Smartphone. It's That Simple.Sync your desktop iTunes® music files with your BlackBerry® smartphone. BlackBerry® Media Sync makes getting more from your music quick and easy!1,2,3,4 Want a specific playlist for the gym?