Skip to Content
0

Mapping Issue

May 11, 2017 at 09:12 AM

77

avatar image

Hi,

I am facing a issue in mapping . I have a file which has two types of indicators A and B and the target node is getting created based on the Type field.

Sample XML :-

<Details> <Records> <Type>A</Type> <ID>12345</ID> <Qty>100.20</Qty> </Records> <Records> <Type>A</Type> <ID>12345</ID> <Qty>101.20</Qty> </Records> <Records> <Type>M</Type> <ID>67890</ID> <Qty>102.20</Qty> </Records> <Records> <Type>M</Type> <ID>67890</ID> <Qty>103.4</Qty> </Records> <Records> <Type>A</Type> <ID>67890</ID> <Qty>105.6</Qty> </Records> </Details>

In this case it should generate 2 files. One file will club the ones with Type A and the other one with Type M.

Now the problem is when I get a file with different Types ( A and M ) for the same ID.

<Details> <Records> <Type>A</Type> <ID>12345</ID> <Qty>100.20</Qty> </Records> <Records> <Type>A</Type> <ID>12345</ID> <Qty>101.20</Qty> </Records> <Records> <Type>M</Type> <ID>67890</ID> <Qty>102.20</Qty> </Records> <Records> <Type>M</Type> <ID>67890</ID> <Qty>103.4</Qty> </Records> <Records> <Type>M</Type> <ID>12345</ID> <Qty>106.6</Qty> </Records> <Records> <Type>M</Type> <ID>12345</ID> <Qty>107.6</Qty> </Records> </Details>

In this case 3 files need to be generated one for Type A , one for Type M and another one for same ID ( 12345 ) but with different type M.

My Logic is below in Mapping

For ID :-

ID -> removecontext-->sort --->SplitbyValue(Value Change)-->collapsecontext ---> MT_Message

For Type :-

Type ---removecontext --------------------------------------------------

FormatByExample---ZType

ID ------removeContext---sort---SplitByValue(ValueChange)----

Kindly let me know how the above query can be resolved. Is there a need to write some UDF for this .

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Muni M May 12, 2017 at 12:20 PM
1

You can do it without using udf. this is all about managing the context.

mapping.jpg

but it will work only for the above order.

if it is mixed,above mapping logic wont work.

<Details> <Records> <Type>A</Type> <ID>12345</ID> <Qty>100.20</Qty> </Records> <Records> <Type>A</Type> <ID>12345</ID> <Qty>101.20</Qty> </Records> <Records> <Type>M</Type> <ID>67890</ID> <Qty>102.20</Qty> </Records> <Records> <Type>M</Type> <ID>67890</ID> <Qty>103.4</Qty> </Records> <Records> <Type>M</Type> <ID>12345</ID> <Qty>106.6</Qty> </Records> <Records> <Type>M</Type> <ID>12345</ID> <Qty>107.6</Qty> </Records> <Records> <Type>A</Type> <ID>12345</ID> <Qty>100.20</Qty> </Records></Details>


mapping.jpg (132.4 kB)
Share
10 |10000 characters needed characters left characters exceeded
Muni M May 12, 2017 at 02:23 PM
0

just want to add, if the sender is not in order, you can use one more mapping to sort the xml and then use above mapping to split.

one mapping is to sort and another one is to split.

Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov May 12, 2017 at 06:36 PM
0

Hi Amit!

Regards, Evgeniy.


group-01.png (48.8 kB)
group-02.png (36.4 kB)
Share
10 |10000 characters needed characters left characters exceeded