on 05-14-2013 8:35 PM
Hi Guru's,
I need to map one filed based on some condition.
Suppose my source value for the 'field1' is abc-123 then I need to remove all the content before '-' and then map the rest of the content i.e 123.
Is this possible using graphical mapping (pls provide the screen shot), or do I need to write UDF, If yes pls provide example.
Input for field F1 Output should be
abc-123 123
xyz-456 456
pqr789 pqr789
123-ijk ijk
Appreciate your help
Thanks
Arun
u ll try below simple udf:
public String calculate1(String a, Container container) throws StreamTransformationException{
int index1 = a.indexOf("-");
if (index1 != -1 )
{
return (a.substring(index1+1));
}
else
{
return (a);
}
thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arun,
for the input value pqr789 , the expected out- pqr789.
If the this is not typo - then you cant achive this requirement with substring function.
You can go for fix values , if you know what are all the input values you can expect for that particular input field.
if not fix values wont work in this case too.
if your answer is NO in both the cases - go for UDF
believe this help,
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi ,
There is an option in PI Fix Values Go to Conversions --> Fix Values.
By using this function you can acchive this easily.
Regards,
Manigandan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi arun,
you Dont need to write UDF, you can achieve this by using simple message mapping.
You can use sub-string function which is available under test functions in message mapping.
for ex:
it will read the character which is there at 4th position (i.e from 1 ) to till 7th character (i.e 3).
so the output will be 123.
Hope it will helpful..
Regards
Bhargava Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arun,
use UDF like below for the field1 in mapping
Signature variables : argument field1 string
public String field1_Substring(String field1, Container container) throws StreamTransformationException{
String result="";
int len=field1.length();
int len1=len-3;
result=field1.substring(len1,len);
return result;
Regards,
Bhavani
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi arun,
you Dont need to write UDF, you can achieve this by using simple message mapping.
You can use sub-string function which is available under test functions in message mapping.
for ex:
it will read the character which is there at 4th position (i.e from 1 ) to till 7th character (i.e 3).
so the output will be 123.
Hope it will helpful..
Regards
Bhargava Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have this UDF:
The input is var1, execution type single values:
int w = var1.indexOf('-');
if(w!=-1)
{
String Stt = var1.substring(w+1, var1.length());
return Stt;
}
else
return St;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
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.