on 05-06-2015 10:27 AM
Hi All,
My requirement is that I need to check if E1P0001-->PERNR = E1P0105-->PERNR, if yes then I need to pass corresponding E1P0105-->USRID-LONG to the target field of record else blank. so I have done following mapping:
checkPernr code is:
String a = "";
for(int i=0;i<var1.length;i++){
for(int j=0;j<var2.length;j++){
if(var1[i]==var2[j])
{
a = var3[j];
result.addValue(a);
break;
}
}
}
Display queue of checkPernr is as follows:
Now the issue is like we see in third context in which for E1P0001-->PERNR 11003877 there is not matching E1P0105-->PERNR, so no value is returned. I want to generate a blank context there.
Now if I write something in else part like:
String a = "";
for(int i=0;i<var1.length;i++){
for(int j=0;j<var2.length;j++){
if(var1[i]==var2[j])
{
a = var3[j];
result.addValue(a);
}
else
{
a = "";
result.addValue(a);
}
}
}
the display queue is like below generating extra [] segments.
How should I handle this requirement now, please suggest?
Regards,
Sachi
hi Sachi,
String a = "";
boolean flag = false;
for(int i=0;i<var1.length;i++){
for(int j=0;j<var2.length;j++){
if(var1[i]==var2[j])
{
a = var3[j];
result.addValue(a);
flag = true;
break;
}
}
}
if(!flag)
result.addValue("");
Please use this code.
hope this helps.
thanks and regards,
Praveen T
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
String a = "";
boolean flag = false;
for(int i=0;i<var1.length;i++){
for(int j=0;j<var2.length;j++){
if(var1[i]==var2[j])
{
a = var3[j];
result.addValue(a);
flag = true;
break;
}
}
}
if(!flag)
result.addValue("");
The flag check should be inserted just after the second for loop ends. It should be like this
String a = "";
boolean flag = false;
for(int i=0;i<var1.length;i++){
for(int j=0;j<var2.length;j++){
if(var1[i]==var2[j]){
a = var3[j];
result.addValue(a);
flag = true;
break;
}
}
if(!flag){
result.addValue("");
}
}
Regards,
Mark
Hi Dubey,
Try this UDF.
Execution Type: All Values Of Context.
public void mapUserIDLong(String[] pernr_01, String[] pernr_05, String[] userID, ResultList result, Container container)
throws StreamTransformationException {
Map pernrMap = (Map) container.getParameter("pernr");
if (pernrMap == null) {
pernrMap = new HashMap();
for (int i = 0; i < pernr_05.length; i++) {
pernrMap.put(pernr_05[i], userID[0]);
}
container.setParameter("pernr", pernrMap);
}
for (String pernr : pernr_01) {
if (pernrMap.containsKey(pernr))
result.addValue(pernrMap.get(pernr));
else {
result.addValue("");
}
}
}
Regards,
Praveen.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.