cancel
Showing results for 
Search instead for 
Did you mean: 

Graphical mapping requirement

Former Member
0 Kudos


Hello Experts,

Can someone help me in this mapping :

Source XML :

<Root>

<Person>

   <PersonNumber>1234</PersonNumber>

- <Details>

  <Country>XXX</Name>

</Details>

</Person>

<Person>

   <PersonNumber>1234</PersonNumber>

- <Details>

  <Country>YYY</Country>

</Details>

</Person>

<Person>

   <PersonNumber>4321</PersonNumber>

- <Details>

  <Country>ZZZ</Country>

</Details>

</Person>

</Root>

Target XML :

<Root>

<Person>

   <PersonNumber>1234</PersonNumber>

- <Details>

  <Country>XXX</Name>

</Details>

- <Details>

  <Country>YYY</Country>

</Details>

</Person>

<Person>

   <PersonNumber>4321</PersonNumber>

- <Details>

  <Country>ZZZ</Country>

</Details>

</Person>

</Root>

The requirement is if the PersonNumber is same for any two occurence then we have to create only one Person node with the </Details> collated.

Rest all data will be passed as it is.

We have to do it only for a maximum of two occurences i.e. one person number can occur for a maximum of two times.

We want to achieve thsi using Graphical maaping.

Thanks

Gaurav

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Gaurav,

Please see the following:

Result Wanted:

Here your Result.

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Thanks a lot Tejas....

Former Member
0 Kudos

Hi Gaurav,

You are welcome Gaurav. Glad that I could Help.

Thanks & Regards,

Tejas Bisen

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Gaurav,

Please try the following Mapping with some changes:

Use the same Mapping for Details Node as used for PersonNumber and Person

Take the input after SplitByValue[ValueChange] from Above and use it as shown below:

[Input1 for FormatbyExample]SplitByValue[ValueChange]--->

                                                                                                  FormatbyExample ---> Country

[Input2 for FormatbyExample]Country---->RemoveContext---->

Hope this Helps,

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Thanks Gerald/Tejas ,

This mapping works fine when there is only one detail record per employee. IF the detail record repeat itself then it fails.

I want AAA BBB and DDD to come under number 1234.

CCC under 4321.

Format by Example will also not work as there is difference in the number of queue entries for Person number and Detail records.

Thanks

Former Member
0 Kudos

Hi Gaurav,

Did you try the change I suggested. Please post images of your Mapping of every field like Gerald did.

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Hello Tejas ,

I have tried the two approach.

1. As suggested by Gerald. This works for single detail record per person.

2. If i map the country field as suggested by you then format by example will not work.

Thanks

Former Member
0 Kudos

Hi Gaurav,

Following is my Solution to your Problem:

This Mapping will work irrespective of the order of the Personno.

P.S: Make Country Context  and PersonNo Context for UseoneasMany Function as Person.

Following is the screenshot of the Test I performed:

I finally got hold of a System as your issue wasn't getting resolved

Hope This helps.

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Thanks for your time Tejas ,

Its very close, just the Detail node should get repeated on target side instead of country...

So i should see 3 details node created under person 1234 with one country each.

In short the requirement is to combine the details node if the person number is same.

Any chance that can be achieved?

This should happen irrespective of the order of Person number.

I.e. input can be 1234 4321 1234

Thanks

gerald_kilgus
Explorer
0 Kudos

Hi Gaurav,

this would be my solution, which is similar to what the other guys were saying.
Move context of source field PersonNumber up one level to <root> and apply the following mapping

to Person and PersonNumber

You need to apply the same logic to details as well:
A somewhat overdesigned mapping would be:
The marked part alone would also do the job

Or if you want the whole mapping grouped in one:

Cheers

Gerald

Former Member
0 Kudos


Thanks Gerald ,

This does solves my first issue.

One more requirement is the country field can repeat itself. I am doing this test as part of a big requirment.

I want values AAA & BBB also to be printed in the details node of Person number 4321.

I have tried using SortBYkey in combination with PersonNo. but that will not work as two queues are having different number of values.

Any ideas on how to solve this?

Thanks.

Former Member
0 Kudos

Hi Gaurav,

In the Target, make your Country Field as 0... Unbounded and maybe your next requirement will get covered.

You can use FormatbYExample to arrange the queue for Country for Target.

For this you will need to take the output of Person right after SplitbyValue(which is being given to PersonNO.) but before collapsecontext as an input to FormatByexample.

Thanks &  Regards,

Tejas Bisen

gerald_kilgus
Explorer
0 Kudos

Hi Gaurav,

that should already with the mapping that I have posted before.

See my test:

or is this not what you wanted?

Cheers

Gerald

Former Member
0 Kudos

Hi Gerald,

Nice you have access to a SAP PI system... I am just trying to do that mapping in my head with all sorts of combinations...I dont have access to system currently.

Kudos to you for actually making the whole scenario.

Thanks & Regards,

Tejas Bisen

gerald_kilgus
Explorer
0 Kudos

Hi Tejas,

designing a mapping without PI access is like playing chess without having the board in front of you.

(at least when it comes down to details questions like these.)

So kudos to you for solving the issue in your head.

Cheers

Gerald

Former Member
0 Kudos

HEllo Gerald ,

I have done exactly mentioned by you. The context to PersonNo for each mapping has been chnaged to Root.

But when testing i am not getting the expected output.

The Country value is not repating. Can you please let me know what is wrong?

Thanks

Former Member
0 Kudos

Hi Gaurav,

Are you sure the Country Field in Datatype [target side] is 0..Unbounded.

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Thanks Tejas/Gerald ,

The last requirement is if the detail node repeat itself then all the detail record for a particular employee should be collated together.Which is not happening as per thsi mapping. Please note Detail node is already 0....unbounded.

Thanks

Former Member
0 Kudos

Hi Gaurav,

I was speaking about the country field on the Target side... if that is not 0..Unbounded...Also just Map a constant to Detail of the Target side.

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Hi Tejas

Yes i got that...but if the detail node is repeating as per screenshot above then how can we collate all the detail nodes of a particular emplyee i.e. 1234 in one single person node??

Twomore detail nodes having bbb & xxx value ofcountry shd get created and ggg should be passed to detail node of 4321.

Thanks

gerald_kilgus
Explorer
0 Kudos

Hi Gaurav,

did you really follow Tejas advice on the cardinality of the target nodes?

This is how it should look like:

I checked my mapping with your data and it produces what you required:

I cannot see any difference between your mapping and my mapping, so it must the the cardinality.

Cheers

Gerald

Former Member
0 Kudos

Hi Gaurav,

Souvik's approach will surely work.

Adding to his approach. Map the PersonNumber Field to Detail of Target. This will create the correct no. of Detail nodes required for populating the country field.

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Hello Tejas/Souvik ,

This does not solve my issue. Collapse contexts is only takin gthe one employee 1234 and is skipping 4321 employee number.

Also the target XML is not generating correctly.

Person node is also repatign three times however it should only occure twice.

Output as per your approach :

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_TRGT xmlns:ns0=">

   <Root>

      <Person>

         <PersonNo>1234</PersonNo>

         <Details>

            <Country>XXX</Country>

         </Details>

      </Person>

      <Person>

         <Details>

            <Country>YYY</Country>

         </Details>

      </Person>

      <Person>

         <Details>

            <Country>ZZZ</Country>

         </Details>

      </Person>

   </Root>

</ns0:MT_TRGT>

Thanks

Former Member
0 Kudos

Hi Ranjan,

Did you apply SplitbyValue as mentioned by Souvik. Having a context in between is very necessary.

I would be happy if you could show the mapping for PersonNo. with Queues

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Yes i applied.

Screenshots:

Thanks

Former Member
0 Kudos

Hi Gaurav,

Please move RemoveContext before SplitbyValue. Your issue will resolved.

Thanks & Regards,

Tejas Bisen

Former Member
0 Kudos

Hello Tejas ,

Still near around same output , but not the one i want.

   <Root>

      <Person>

         <PersonNo>1234</PersonNo>

         <Details>

            <Country>XXX</Country>

         </Details>

      </Person>

      <Person>

         <Details>

            <Country>YYY</Country>

         </Details>

      </Person>

      <Person>

         <Details>

            <Country>ZZZ</Country>

         </Details>

      </Person>

   </Root>

Thanks

Former Member
0 Kudos

You will have to use the same mapping for Person Node as well.

Also, please check if after collapse context, you can see 1234 and 4321 in the Queue. If yes, and there is no Context Change, use SplitbyValue (AnyValue) Again.

Thanks,

Tejas Bisen

Former Member
0 Kudos

Hi Gaurav,

You can map the field PersonNumber to "Split By Value Changed" function, this in turn can be mapped to "Remove Context" function, which then should be mapped to "Collapse Context" function, and finally it being mapped to the target field "PersonNumber".

Explanation for the above : "Split By Value Changed" will split depending upon the change in value. "Remove Context" will group all those same values under one context. Finally, "Collapse Context" will choose the first element from each of those resulting context.

Regards,

Souvik