cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Doubt

Former Member
0 Kudos

Hi Experts,

My requirement is I will get queue of values for two source fields (Var1, Var2), when ever both are equal those many times third source field should send to target.

Attached is the image of my mapping (which is i am getting (wrong))

I tried below UDF's with execution type "All values of queue" , Please check and correct the UDF based on my below expected mapping.

UDF1: (Not working as expected)

int len = var1.length;
int key =0;
String[] finalval = new String[len];

while(key<len)
{

for(int i=0;i<var2.length;i++)
  {
    if(var1[key].equals(var2[i]))
    result.addValue(var3[i]);
  }
key++;
}

UDF2: (Not expected as expecting)

int a=var1.length;

int b= var2.length;

for(int i=0;i<a;i++)

{

for(int j=0;j<b;j++)

{

if(var2[j].equals(var1i ))  ("i" is under square brackets)

{

result.addValue(var3[j]);

}

}

}

Attached is the image of my mapping (which is i am expecting (If i pass same values two times i am getting this, But expected source values are different))

Thanks & Regards,

A.Neelima.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Neelima, Can you try below code, I might have not got your conditions correctly(bit confusing). Let me know if this is what you were looking at -

for (int i=0;i<var1.length;i++)

{for (int j=0;j<var2.length;j++)

  { if (var1[i].equals(var2[j]) )

         result.addValue(var3[j]);

      continue;

  }

}


- Amol

Former Member
0 Kudos

Hi Amol,

Thanks for your reply.

Its not working, I am getting same output.

As shown in your disply list: Pass the below values and see the output.

My requirement is : (I am comparing both in0 and in1 and when ever those are equal i am passing the in2 value to result, in below example its two times equal (3 and 4)).

in0:

3

4

in1:

1

2

3

4

in2:

GL

COST

GL

COST

Now you will get output as below by using all the UDF's mentioned in chain.

out:

GL

COST.

But i am expecting output as below : (I am comparing both in0 and in1 and when ever those are equal i am passing the in2 value to result, in our example its two times equal (3 and 4)).

out:

GL

COST

GL

COST

Thanks & Regards,

A.Neelima.

former_member184720
Active Contributor
0 Kudos

>>>But i am expecting output as below : (I am comparing both in0 and in1 and when ever those are equal i am passing the in2 value to result, in our example its two times equal (3 and 4)).


Your requirement is a bit unclear. What do you mean by passing in2 value to result when they are equal?

If there is a match then you want to return all the values of in2?

for the below input, what is the expected output and what basis?

in0:

3

4

in1:

1

2

3

4

in2:

a

b

c

d

Former Member
0 Kudos

I will explain my requirement again.

Source structure:

ST

  --->GenericLineItem

            --> AccountNumber

            -->LineItemRefNum

                         -->Value

  --->AllocationLineDetails

            --->AccountNumber

Target Structure

TT

  ---> ZORDETAIL

           -->Cost

My mapping logic for target node Cost is , it will compare AccounNumber under AllocationLineDetails and GenericLineItem if its equal value under LineItemRefNum will be passed.
If its single value means my UDF is working, I will get multiple contexts from source (Duplicate sub trees) here i am facing problem.
Hope its clear now
Thanks & Regards,
A.Neelima.
former_member184720
Active Contributor
0 Kudos

Provide the sample input and expected output.. i.e. failure case.

Former Member
0 Kudos

Just to add, As you said in example:

in0 : (take Accountnumber under allocationlinedetails)

3

4

in1 : (take Accountnumber under GenericLineItem)

1

2

3

4

in2 : (take Value)

a

b

c

d

Output is:

c

d

Because Account numbers are same in 3 and 4 values.

Thanks & reagrds,

A.Neelima.

Former Member
0 Kudos

Hi, Why you have repeated GL & COST again, Is it because it's repeating in in2 context itself?

Former Member
0 Kudos

Yes, Its repeating in in2 context.

Thanks & reagrds,

A.Neelima.

Former Member
0 Kudos

hi Neelima,

is GenericLineItem and AllocationLineDetails are at same level? Which structure is repeating? GenericLineItem? or both?

former_member194481
Participant
0 Kudos

Hi Neelima,

Provide your input and expected output (sample payload), requirement was not yet clear to try for me

BR,

Vijay

markangelo_dihiansan
Active Contributor
0 Kudos

Hi Neelima,

Amol's code is almost working, you just need to remove the continue


for (int i=0;i<var1.length;i++)

{for (int j=0;j<var2.length;j++)

  { if (var1[i].equals(var2[j]) )

         result.addValue(var3[j]);

  }

}

The code above should work. See screenshot below:

Hope this helps,

Mark