cancel
Showing results for 
Search instead for 
Did you mean: 

mapping issue

Former Member
0 Kudos

Hello all,

My requirement is i have to map one element of i doc segment(may occure multiple times) to a element of target xml(max occur=1). If the idoc segment occures multiple times i need to concate all those values into single target xml element. Also i have one check condition for parent segment of source. I tried combination of graphical and java mapping but unable to get the requirement done. Can any one suggest me good solution for this mapping.

Accepted Solutions (1)

Accepted Solutions (1)

former_member187339
Active Contributor
0 Kudos

Hi Sandip,

>>f the idoc segment occures multiple times i need to concate all those values into single target xml element.

Use this udf

Advanced udf for all values in a queue


String output = null;

for (int i=0;i<input.length;i++){
 ouput += input<i>;
}

result.addValue(output);

>>lso i have one check condition for parent segment of source.

Use standard if then else functions in the graphical mapping to achieve this

Regards

Suraj

Former Member
0 Kudos

hi suraj

i have tried the fallowing code ,,,,,,,,,

String outText = null;

try {

for ( i = 0; i < textCount[0] ; i++)

{

outText += inText<i>;

}

result.addValue(outText);

result.addContextChange();

}

catch(Exception e)

{

}

in textCount i am passing the value of no of segment.

but i think the context is not geting switched in for loop, so i am not geting proper output.

former_member187339
Active Contributor
0 Kudos

Hi Sandip,

>>textCount i am passing the value of no of segment.

Why you wan to pass the value of number of segments like this? IF you take the size of the input array (input) then you will get the number right?

>>but i think the context is not geting switched in for loop, so i am not geting proper output.

Need few more info, can you show me the value in display queue for the input and output of this udf? And what is the type of udf (is it for each value in a context or queue)

Also you can put context change using splitbyvalue node function

Regards

Suraj

Former Member
0 Kudos

Hi Suraj,

values getting concatenated when i changed the UDF type to all values in Queue.

Previously it was all values in context. Can u tell me the difference between these types.

Many thanks,

Sandip

former_member187339
Active Contributor
0 Kudos

Hi Sandip,

Just search sdn and you will get threads on this. For eg:

Regards

Suraj

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

1.

If the idoc segment occures multiple times i need to concate all those values into single target xml element.

For this write a UDF.

All values of context.

Input:source,container,result

Output:void.

-


String temp = "";

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

{

temp = temp+source<i>;

}

result.addValue(temp);

-


2.Also i have one check condition for parent segment of source

Use Exists function to check for the existence of source node..

I hope this wil solve ur prblm...

In case still prblm occurs plz do post..

Babu

former_member200962
Active Contributor
0 Kudos

for the first one, you have to implement a UDF which will concat values of all the re-curring nodes and then pass it as one single string to the target