cancel
Showing results for 
Search instead for 
Did you mean: 

File-idoc(Mapping after subtraction of source fileds internally)

Former Member
0 Kudos

Hello,

I have an <b>IDOC-File</b> scenario where....

<b>SOURCE:</b>

SEGMENT1 1..N

FIELD1 1..1

CHILD1 1..N

CHILD2 1..N

<b> TARGET</b>

FIELD1 1..1

Now the situation is sum of child1 & child2 (which has occurrence 1..n) should be subtracted from field1(source) and the result is then mapped to field2(target).

I am expecting a feasible solution from you guys....

Awaiting your reply..thanks in advance

Hari

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

You can do that by defining a simple java function in <b>user defined</b> in the grafical mapping editor. You have just to create one. Your entries will be CHILD1 and CHILD2. You have to mark your function as a <b>queue</b>. Then you add and substract the values.

Former Member
0 Kudos

You can access to all the values by using a "for" like this one:

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

child1=child1+a;
}

Then you do the same for child2 (b) and the do the substraction.

Regards

Gonzalo

Former Member
0 Kudos

Hi Gonzalo,

Thanks for your very good solution.

But i am not aware of Java functions and request you to provide me the complete coding.

Note : Child1&child2&child3 and so on are with occurance 1...n

Regards

Hari

Former Member
0 Kudos

Voila:

   //write your code here
int child1=0;
int child2=0;
int child3=0;
int field1=0;
for ( int i = 0; i < a.length; i++ ) {
 
child1=child1+Integer.parseInt(a<i>);
}
for ( int i = 0; i < b.length; i++ ) {
 
child2=child2+Integer.parseInt(b<i>);
}
for ( int i = 0; i < c.length; i++ ) {
 
child3=child3+Integer.parseInt(c<i>);
}
for ( int i = 0; i < d.length; i++ ) {
 
field1=field1+Integer.parseInt(d<i>);
}
int s=child1+child2+child3-field1;
String s2 = String.valueOf(s);
result.addValue(s2);

Regards

Gonzalo