cancel
Showing results for 
Search instead for 
Did you mean: 

mapping question

Former Member
0 Kudos

source:

<Row>

<date>20070101</date>

<company>1000</company>

<amount>100.00</amount>

<Row>

<Row>

<date>20070101</date>

<company>1000</company>

<amount>200.00</amount>

<Row>

<Row>

<date>20070101</date>

<company>2000</company>

<amount>500.00</amount>

<Row>

<Row>

<date>20070101</date>

<company>2000</company>

<amount>600.00</amount>

<Row>

<Row>

<date>20061220</date>

<company>3000</company>

<amount>50.00</amount>

<Row>

<Row>

<date>20061220</date>

<company>3000</company>

<amount>10.00</amount>

<Row>

expected target:

<Row>

<company>1000</company>

<date>20070101</date>

<amounts>

<amount>100.00</amount>

<amount>200.00</amount>

</amounts>

</Row>

<Row>

<company>2000</company>

<date>20070101</date>

<amounts>

<amount>500.00</amount>

<amount>600.00</amount>

</amounts>

</Row>

<Row>

<company>3000</company>

<date>20061220</date>

<amounts>

<amount>50.00</amount>

<amount>10.00</amount>

</amounts>

</Row>

I need the mapping step(s) for the date field. The company is mapped when there is a change in company and till that change, the amounts are correspondingly moved. How do I do this with the date that corresponds with a particular company?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

You need to do this with the help of UDF mapping.

In Udf you need to imply the logice such a way that the Amounts will be rearranged as per the company.

For e.g. Check for company 1000 and then add corresponding amount field in result list.after change in company code add the context change, thus the receiver structure can be achived

If you have time let me know I could develop similar Java code for you and share with you. (It will bit time consumable activity due to take some time from my daily routine work ...:-)) )

Thanks

Swarup

Former Member
0 Kudos

I think it should be possible without any custom java UDF by using node functions, just not able to get a good handle on how.

Former Member
0 Kudos

Hi,

Please find her ewith you the udf code for Amount field

Here pass Company as A and Amount field as B.

The below Udf is for amount field

String Company = new String(A[0]);

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

{

if(Company==A<i>)

{

result.addValue(B<i>)

}

else

{

Company = A<i>;

result.addContextChange();

i--;

}

}

Please check the syntax of the code.

UDF for Company field or Date field as A

String temp = new String(A[0]);

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

{

if(temp!=A<i>)

{

result.addValue(B<i>)

result.addContextChange();

}

}

thanks

Swarup

Former Member
0 Kudos

You are quick! Thanks, solved the problem. Points awarded. 😞

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I think you can perform it with nodefunctions by using

Use these one for company code

RemoveContext

Sort

SplitByValue (on ValueChange)

CompCode ---> RemoveContext ---> Sort ---> SplitByValue (on Value Change) -


> TargetNode

Use these one for amount and date as well

FormatByExample (in the upper box map Amount ---> RemoveContext and lower box map company code with the same functions as mentioned avove) -


> TargetNode.

While using FomatByExample, context should be same.

Do same for date.

This is a general idea, u have to think a bit abt it and then i guess u can achieve the goal.

Regards,

Sarvesh

justin_santhanam
Active Contributor
0 Kudos

James,

Are u sure that company will always come in sequential order, I mean

Company ID

1000

1000

1000

Change in Company ID

2000

2000

Plz confirm that u won't get the data in below sequence

Company ID

1000

1000

Change in comp ID

2000

2000

Change in comp ID

1000

1000

raj.

Former Member
0 Kudos

Correct, company will always be in sequence. The date however could be anything but will be same for a given company. The corresponding date needs to be moved when the new <Row> is created for new company.