cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to map header and detail records

Former Member
0 Kudos

Hi,

Scenario : There is one source structure as beow :

<structure>

<Store_No/>

<Employee_No/>

<First_Name/>

<Middle_Name/>

<Last_Name/>

</structure>

This is for a single record. If more records are there, the structure is duplicated/appended.

The target structure required is for repeating "structure" above (i.e. more than one source structure) :

<Header>

<Record_Type>1</Record_Type>

</Header>

<Employee_Data>

<Record_Type>2</Record_Type>

<First_Name/>

<Middle_Name/>

<Last_Name/>

</Employee_Data>

<Header>

<Record_Type>1</Record_Type>

</Header>

<Employee_Data>

<Record_Type>2</Record_Type>

<First_Name/>

<Middle_Name/>

<Last_Name/>

</Employee_Data>

For one source "structure" it works fine. But when there is more than one structure it does not work. Could you please tell me an UDF for the same to work. Awaiting your replies. Points will be awarded once I get the correct solution. Thanks in advance.

Regards,

Deb.

Accepted Solutions (1)

Accepted Solutions (1)

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

Is this structure correct?

<Messages> 1..1

-


><Messages1> 1..1

-


><Root> 0..unbounded

-


><Header> 1..1

-


> <Record_Type> 0..1

-


><Employee_Data> 1..1

-


> <Record_Type> 0..1

-


> <First_Name> 1..1

-


> <Middle_Name> 1..1

-


> <Last_Name> 1..1

Then you can do the following mapping:

for the Root:

Employee_No --> removeContext --> sort:Numerical Ascending --> splitByValue:ValueChanged --> collapseContext --> Root

The assumption here is that there is a unique employee number per employee, the above logic is to eliminate duplicates that could happen

for both Record_Type use constants

for the First Name:

Employee_No --> removeContext --> 1.sortByKey:Numerical Ascending -->

First_Name --> removeContext -


> 2. sortByKey:Numerical Ascending

splitByValue:ValueChanged --> collapseContext --> splitByValue:Each Value --> First_Name

This logic is almost the same as the root, it takes into consideration duplicate entries

for Middle_Name and Last_Name just replace the logic in First_Name

This should work

Regards

Edited by: dspboys on Jan 20, 2009 9:24 AM

Former Member
0 Kudos

How do we map the "Header" and the "Employee_Data" node? I tried your logic but its showing some Message mapping error in the Header n Employee_Data?

markangelo_dihiansan
Active Contributor
0 Kudos

Hi,

Is your target structure same as what is specified in my post? Since the occurrence of the Header and Employee_Data is 1..1, there should be no need to do any mapping. Could you please give me the error that is being displayed?

Edited by: dspboys on Jan 20, 2009 10:52 AM

Former Member
0 Kudos

Thanks for your help Sir...I got it solved.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Change the occurence to 0-unbounded for multiple set of records with same structure.

Regards,

Prakasu

Former Member
0 Kudos

It is already 0-unbounded for the target as well as source. Can u let me know whether it is possible by using standard function to acheive this or do we need to write an UDF for it?