cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced User Defined Function

Former Member
0 Kudos

Dear All,

I have a target structure as follows:

<Item>

<Record10>

<RecordType>

<BankCode>

<AccountID>

<Amount>

</Record10>

<Record50>

<RecordType>

<Segment1>

<segment2>

<segment3>

</Record50>

</Item>

I want to fill the elements in the Record50 in a special way by using some logic. Sometimes I may have to create multiple Record50 structures. So I'm using an advanced user defined function to do this.

My mapping is as follows:

Source Structure -> myFunction()->Record50

And in myFunction() I wrote the following piece of code:

result.addValue("50");

result.addValue("PayRef1");

result.addValue("Address");

result.addValue("Nil");

I expect the output to be:

<Record50>

<RecordType>50</RecordType>

<Segment1>PayRef1</Segment1>

<segment2>Address</segment2>

<segment3>Nil</segment3>

</Record50>

But the output is like this:

<Record50>50</<Record50>

<Record50>PayRef1</<Record50>

<Record50>Address</<Record50>

<Record50>Nil</<Record50>

Can somebody tell me how to proceed? I tried to insert a context change in the beginning, but then the Record50 itself is not appearing.

Thanks,

Sandeep

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member206604
Active Contributor
0 Kudos

Hi,

Advanced UDF will not create you like you expected.

You need to do like this

Source>myFunction1()-><RecordType>

And in myFunction() you do code:

result.addValue("50");

Source>myFunction2()-><Segment1>

And in myFunction2() you do code:

result.addValue("PayRef1");

so on..

Thanks,

Prakash

Former Member
0 Kudos

Hi Sandeep,

the way you do it, you need FOUR UDF:

1) result.addValue("50");

2) result.addValue("PayRef1");

3) result.addValue("Address");

4) result.addValue("Nil");

Than you have to map

<RecordType>50</RecordType> -> 1

<Segment1>PayRef1</Segment1> -> 2

<segment2>Address</segment2> -> 3

<segment3>Nil</segment3> -> 4

Regards Mario

bhavesh_kantilal
Active Contributor
0 Kudos

Sandeep,

When you use an Advanced USer Defined Function, you can return multiple values out of the UDF< but you cannot dynamically create the TARGET ELEMENT as you want.

You will need to repeat the same UDF for each TARGET ELEMENT as per the logic and create the target element.

Regards,

Bhavesh