on 01-05-2011 1:20 PM
Hi Everyone,
I am learning PI and currently working on UDF.
I am interface Z RFC to update the data from external system.
When the data is staged at XI i need to concatenate two fields and store into third in message mapping.
I am writing an UDF for this.
For example :
source structure.
emp_id
emp_name
emp_sal
date_time
first_name
last_name
gender
dept_id
target strucutre( strucutre in sap)
ZEMPID
ZEMPNAME
ZEMPSAL
ZDEPTID
ZDATE
ZTIME
I need the steps (including execution type ) to concatenate fields first_name and last_name into zempname in UDF only.
Can you pls give me the steps and code.
Regards,
Vinay
Go through this u will fulfill ur requirement easily.
(Graphical mapping all functions)==>
http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
Some more helpful links are....
Like where u can use UDF
User Defined Function==>
http://help.sap.com/saphelp_nwpi71/helpdata/EN/22/e127f28b572243b4324879c6bf05a0/content.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Vinay,
I believe this is for your understanding purpose as to how UDF works.
1. Create UDF with two input parameters of type string.
2. Type of the UDF be single value function.
3. Inside the UDF, you can use Java function concat with the input parameters and place the resultant into a String variable
4. Using the return statement return the resultant String variable.
After creating the UDF. The UDF appears along with the standard functions in the graphical editor.
Coming to the graphical mapping:
Use the source nodes first_name and last_name as input parameters for your UDF and the output of the UDF into the target field ZEMPNAME.
Prerequisite: You should know Java coding.
Hope it is clear.
Regards,
Anand Patil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey Vinay,
step 1: Create a UDF (concatString) with two input parameters (str1, str2) of type string.
step2: Inside the UDF, write code to concate the strings , and return the value.
Here, in this case, you just need to write a single line of code in udf. assuming two strings are separated by space " ".
public String concatString(String str1, String str2, Container container) throws StreamTransformationException
return str1+" " +str2;
Hope this help
Edited by: Ritu Sinha on Jan 6, 2011 5:16 PM
Hi Amit,
I used the execution type as "All values of a Context"
my UDF method is as follows
public void jncalculate(String[] var1, String[] var2, ResultList result, Container container) throws StreamTransformationException{
String res="";
res = var1.concat(var2);
return res;
}
system throws the following error.
cannot find symbol symbol : method concat(java.lang.String[]) location: class java.lang.String[] res = var1.concat(var2); ^
Function jncalculate, Line 4:
cannot return a value from method whose result type is void return res; ^ Note: /usr/sap/DX1/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map64de0d15198b11e0a6f80000003b5cae/source/com/sap/xi/tf/_MM_VK_EMP_RFC_IB_.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /usr/sap/DX1/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map64de0d15198b11e0a6f80000003b5cae/source/com/sap/xi/tf/_MM_VK_EMP_RFC_IB_.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 2 errors
Regards,
Vinay
Hi,
Chk this:
/people/rohit.kalugade/blog/2009/02/09/context-and-queue-in-message-mapping-udf-150-part2
http://wiki.sdn.sap.com/wiki/display/XI/UDFExecutionType-ContextandQueue.
Basically when u choose context and queues as execution type then u have play with more than one value for a filed.
Thanks
Amit
>>> need the steps (including execution type ) to concatenate fields first_name and last_name into zempname in UDF only.
This is pretty simple. Don't need UDF. Just use concat standard function
use first_name and last_name as input of concat and map the output to the zempname
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
why an UDF ? use concat function from standard functions (text)
Regards,
Michal Krawczyk
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.