cancel
Showing results for 
Search instead for 
Did you mean: 

One Source and Multiple Target nodes using UDF

Hello Experts,

I'm trying to find a solutions for one of my requirements.

This is my Source

<Header>

<EMPID>12345</EMPID>

<Name>ABC</Name>

<No_of_Hours>16</No_of_Hours>

<Start_Date>12/17/2018</Start_Date>

<End_Date>12/18/2018</End_Date>

</Header>

Expected Target is

<Header>

<EMPID>12345</EMPID>

<Name>ABC</Name>

<No_of_Hours>8</No_of_Hours>

<Start_Date>12/17/2018</Start_Date>

<End_Date>12/17/2018</End_Date>

</Header>

<Header>

<EMPID>12345</EMPID>

<Name>ABC</Name>

<No_of_Hours>8</No_of_Hours>

<Start_Date>12/18/2018</Start_Date>

<End_Date>12/18/2018</End_Date>

</Header>

As per the requirement, if the number of hours is more than 8, another node should be created with same data and dates modified based on start date and end date. such that if a person has clocked for two days, then the source will collate and send as one xml structure, but the target needs two line items based on the available data. assumptions are No_of_Hours field will have the hours only in multiples of 8. There won't be any holidays between startdate and end date. Kindly suggest an approach or an UDF to proceed.

Many Thanks,

Sidharth VR

Accepted Solutions (0)

Answers (1)

Answers (1)

binod8
Active Participant
0 Kudos

Hi Sidharth,

I think of the below steps to achieve this. There might be some change needed since I have not tested this, but if asked I would have suggested below approach.

To create Header:

Create UDF

- Pass No_of_Hours as parameter

- Loop depending on the number of No_of_Hours/8. create that many empty node to the target Header

Note: if the above results in decimal value(for eg. 12/8 = 1.5, then the above logic will still give you one. Please handle this if needed)

To create EMPID

UseOneAsMany node function

First parameter- Pass empid from the source

Second parameter - Pass the output of the above UDF

Third parameter- Pass the output of the above UDF - Split by each value(to give context change)

To create Name

UseOneAsMany node function

First parameter- Pass name from the source

Second parameter - Pass the output of the above UDF

Third parameter- Pass the output of the above UDF - Split by each value(to give context change)

To create No_of_Hours

Create UDF

- Pass No_of_Hours as parameter

- Loop Depending on the number of No_of_Hours/8.

->create node to the target Header passing the value 8. Please pass the last value the actual if it is less than 8.

->add context change after each node creation.

To create Start_Date

Create UDF

- Pass Start_Date and end date as parameter

- Loop from start_date for No_of_Hours/8 times. (again, if the division has decimal value then the loop should be handled to work for one more times or this has to be checked and handled outside the loop)

- Pass the date and create node (note: while incrementing the date please take care of the calendar. for eg after feb 28 2019, date should move to 1 March2019)

- add context change

To create End_Date

Pass the same output of UDF created for Start_Date

Thanks,

Binod