cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping

former_member609026
Participant
0 Kudos

Hi All,

I had a mapping rule where I have to pull specific filed's form source in each context and add them to the target.

for example form the below diagram from the source has two contexts have to pull out 4th field in both contexts. 

target field values would be 4 and 9.

I tried standard function "CopyValue", but it returns value from first context. i.e value 4.

Can I complete this task using standard functions or can do I have to use UDF?

If I have to use a UDF please provide me java code for the same.

Regards,

Pradeep A.

Accepted Solutions (1)

Accepted Solutions (1)

former_member609026
Participant
0 Kudos

Hi All,

Thanks.. hear is the final udf which executed successfully as per my requirement.

public void getValueFromEachNode(String[] input, String[] loc1, ResultList result, Container container) throws StreamTransformationException{

int loc = Integer.parseInt(loc1[0]);

result.addValue(input[loc-1]);

for(int i=5;i<input.length;i++)
{
if(input[i]==ResultList.CC)
{
result.addValue(input[i+loc]);
i=i+5;
}
}

}

Answers (3)

Answers (3)

ambrish_mishra
Active Contributor
0 Kudos

Hi Pradeep,

I don't think you need to run a loop since you just need to pass on a value at a particular index.

Any ways..

Ambrish

ambrish_mishra
Active Contributor
0 Kudos

Hi Pradeep,

paramter name input

Code below:

_________________________________

if(input.length>3)

    result.addValue(input[3]);

else

    result.addValue("");

_________________________________

Ambrish

gagandeep_batra
Active Contributor
0 Kudos

Hi pradeep,

you can go for udf

logic is like below there might be sytex problem plz do needful for that:

ResultList.addvalue(a[3]);

for(i=4;i<a.lenght;i++)

{

if(a[i]==Result.CC)

{

i=i+4;

ResultList.addvalue(a[i]);

}

}

Regards

Gagan

former_member609026
Participant
0 Kudos

Hi All,

waiting for any other replays.

Regards,

pradeep A.