on 11-17-2015 1:26 PM
Hi Everyone,
I have a requirement for one of existing filed in PI mapping. From source PI is receiving 5 input values, using those values PI need to populate the target filed with combination input fields and which needs to implement only by using UDF.
inputs to PI (Source fields) : NAME1, NAME2, NAME3, NAME4 and COUNTRY
Target field: Displayname
Below is the mapping rule..
1) NAME1 is not blank and NAME2 is not blank and NAME3 is not blank and NAME4 is not blank then
DisplayName should be NAME1 +_+ NAME2 +_+ COUNTRY
2) NAME1 is not blank and NAME2 is not blank and NAME3 is not blank and NAME 4 is blank
DisplayName should be NAME1 +_+ NAME2 +_+ COUNTRY
3) NAME1 is not blank and NAME 2 is blank and NAME3 is not blank and NAME 4 is blank
DisplayName should be NAME1 +_+ CITY1
4) NAME1 is not blank and NAME2 is not blank and NAME 3 is blank and NAME 4 is blank
DisplayName should be NAME1 +_+ NAME2+_+ COUNTRY
5) NAME1 is not blank and NAME2 is blank and NAME 3 is blank and NAME4 is blank
DisplayName should be NAME1 +_+ COUNTRY
6) ELSE Display Name “ERROR”
Please help me with java code to achieve this mapping rule.
Thanks in advance..!
--
With Warm Regards
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sateesh,
Due to there are some changes I have modified the code, and getting one issue.
Here the modifications are for example in as per our 1st condition
NAME1 is not blank and NAME2 is not blank and NAME3 is not blank and NAME4 is not blank then
DisplayName should be NAME1 +_+ NAME2 +_+ COUNTRY
instead of "_" PI (underscore) need to create " " (space) between the values.
And instead of COUNTRY PI need to pass the LIFNR value in place of COUNTRY
For exampla if inputs are:
NAME1 : COCA
NAME2: COLA
NAME3: NULL
NAME4: NULL
LIFNR: 10005678
Then target field Display name (as per UDF) : COCA COLA 10005678 (correct output)
But am getting output as : COCA COLA - 10005678 (wrong output)
But here I am not able to find why PI is creating "-" (High-fun) between NAME2 and LIFNR.
Below is the code am using in UDF..
if(NAME1 != "" && NAME2 !="" && NAME3 !="" && NAME4 !="")
{
Name= NAME1+" "+NAME2+" "+LIFNR;
}
else if(NAME1 != "" && NAME2 !="" && NAME3 !="" && NAME4 =="")
{
Name= NAME1+" "+NAME2+" "+LIFNR;
}
else if(NAME1 != "" && NAME2 =="" && NAME3 !="" && NAME4 =="")
{
Name= NAME1+" "+LIFNR;
}
else if(NAME1 != "" && NAME2 !="" && NAME3 =="" && NAME4 =="")
{
Name = NAME1+" "+NAME2+" "+LIFNR;
}
else if (NAME1 != "" && NAME2 =="" && NAME3 =="" && NAME4 =="")
{
Name =NAME1+" "+LIFNR;
}
else DisplayName = "ERROR";
return DisplayName;
Please help me rectifying this issue..
Thanks in advance..!
--
With Warm Regards
Raj
Hi Raj,
Please use following UDF .Take all inputs as a string.
String DisplayName = null;
if(!(NAME1[0].equals("") && NAME2[0].equals("") && NAME3[0].equals("") && NAME4[0].equals("")))
DisplayName = NAME1[0] + "_" + NAME2[0] + "_" + COUNTRY[0];
else if(!(NAME1[0].equals("") && NAME2[0].equals("") && NAME3[0].equals("")) && NAME4[0].equals(""))
DisplayName = NAME1[0] + "_" + NAME2[0] + "_" + COUNTRY[0];
else if(!(NAME1[0].equals("") && NAME3[0].equals("")) && (NAME2[0].equals("") && NAME4[0].equals("")) )
DisplayName = NAME1[0] + "_" + COUNTRY[0];
else if(!(NAME1[0].equals("") && NAME2[0].equals("")) && (NAME3[0].equals("") && NAME4[0].equals("")) )
DisplayName = NAME1[0] + "_" + NAME2[0] + "_" + COUNTRY[0];
else if(!(NAME1[0].equals("") && NAME2[0].equals("")) && (NAME3[0].equals("") && NAME4[0].equals("")) )
DisplayName = NAME1[0] + "_" + COUNTRY[0];
else
DisplayName = "ERROR";
Thanks,
Apu Das
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Das,
I have used the below code and it works fine now.
if(NAME1 != "" && NAME2 !="" && NAME3 !="" && NAME4 !="")
{
Name= NAME1+" "+NAME2+" "+LIFNR;
}
else if(NAME1 != "" && NAME2 !="" && NAME3 !="" && NAME4 =="")
{
Name= NAME1+" "+NAME2+" "+LIFNR;
}
else if(NAME1 != "" && NAME2 =="" && NAME3 !="" && NAME4 =="")
{
Name= NAME1+" "+LIFNR;
}
else if(NAME1 != "" && NAME2 !="" && NAME3 =="" && NAME4 =="")
{
Name = NAME1+" "+NAME2+" "+LIFNR;
}
else if (NAME1 != "" && NAME2 =="" && NAME3 =="" && NAME4 =="")
{
Name =NAME1+" "+LIFNR;
}
else DisplayName = "ERROR";
return DisplayName;
Thanks for your time..!
--
Regards
Raj
User | Count |
---|---|
93 | |
10 | |
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.