on 07-19-2011 2:44 PM
Hi All,
How to read the second value of a context supressing the first one:
for eg:
<N1>1,2<N1>
<N2>3,4<N2>
output will be 2 and 4.Please give your inputs not able to do with graphical?
Regards,
Nkumar
Hi Kumar,
Create a Value user defined function and name it as GetAfterComma. Take one argument as a.
Add this code:
Imports: java.*;
//write your code here
int k = a.length();
int i = a.indexOf(".");
i = i +1;
a = a.substring(i,k);
return(a);
Map like this:
Input field --> UDF --> target field.
So if input is 2,4 then you will have ouput as 4.
Regards,
---Satish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can write simpe udf. Another way to achieve this.....
// pass input String as method argument and return type String
int index1 = input.indexOf(",");
String output = input.substring(index1+1, input.length());
return output;
Edited by: Baskar Gopal on Jul 19, 2011 2:03 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use standard function copyvalue
You can use standard function copyvalue
You can use CopyValue() to copy the value of a position in the source structure and assign it to a target field
see this link for an perfect example
http://help.sap.com/saphelp_nw04/helpdata/en/26/d22366565be0449d7b3cc26b1bab10/content.htm
sourcefield--copyvalue(1)-mapwithdefault--targetfield
Input
ContextChange
2
4
Contextchange
5
7
Contextchange
Output
ContextChange
4
Contextchange
7
Contextchange
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Debasish,
Actually I am getting same 4 nodes carrying differnt value but want to take 2nd and 4th node only.Here I tried copyvalue but not working only getting 1 node...also if 2 nodess coming want to take second node with the target..please suggest
Edited by: NKumar1 on Jul 19, 2011 4:00 PM
Hi KUMAR,
USE the below UDF with execution type All values of context
also make sure input to this UDF .........no contextchange between your four or two values.
public void calculate(String[] var1, ResultList result, Container container) throws StreamTransformationException{
if(var1.length>=4)
{
result.addValue(var1[1]);
result.addValue(var1[3]);
}
else
{
result.addValue(var1[1]);
}
}
Please let know if its helps you
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.