cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping Question - unbounded node not occurring multiple times

0 Kudos

here is a simplified version of my scenario:

Input file looks like this:

<Data>

     <Part>

          <ID>123</ID>

     </Part>

     <Part>

          <ID>abc</ID>

     </Part>

</Data>

Output file needs to look like:

<Data>

     <Sync>

          <ActionE code="Add">123</ActionE>

          <ActionE code="Add">abc</ActionE>   

     </Sync>

     <Item>

          <IDcode>123</IDcode>

     </Item>

     <Item>

          <IDcode>abc</IDcode>

     </Item>

</Data>

I have <ActionE> and <Item> as 0..unbounded.

The <Item> correctly occurs multiple times, I am mapping <Part> to that in the Message Mapping.

The problem:  <ActionE> only occurs one time.  I don't know how to map it properly to occur multiple times like that.  Simply having <ID> in the mapping is not doing the trick.  Can you please help?

Accepted Solutions (1)

Accepted Solutions (1)

Ryan-Crosby
Active Contributor
0 Kudos

Hi Adam,

I'm not sure how you are mapping to ActionE on the target but based on your source sample it looks like you could use a basic mapping of ID -> RemoveContext -> ActionE or also Part -> ActionE.  How exactly are you currently mapping the ActionE element?

Regards,

Ryan Crosby

0 Kudos

Ryan,

Thank you.  RemoveContexts is working.  I am new to SAP PI and need to research that functionality a bit more.

The only piece it didn't do is add in the attribute.  So I am getting:

<ActionE code="Add">123</ActionE>

<ActionE>abc</ActionE>  



While my sample doesn't show it, that "code" attribute is based off of a node that only appears a single time, and i map with the FixValues.

so input more accurate is:

<Data>

     <Type>Create</Type>

     <Part>

          <ID>123</ID>

     </Part>

     <Part>

          <ID>abc</ID>

     </Part>

</Data>


So I am using FixValues to map that <type> into the attribute "code".  Need the attribute for every instance of <ActionE>

Ryan-Crosby
Active Contributor
0 Kudos

Hi Adam,

You can use the following mapping to replicate that value many times:

Type ->

Part  -> useOneAsMany -> RemoveContext -> Code

ID     ->

or:

Type                      ->

ID (context at Part) -> useOneAsMany -> RemoveContext -> Code

ID                          ->

The first option assumes that you only have one ID per Part node.  If that is not the case you can always use the second option but you have to make sure you use the RemoveContext function for the output because useOneAsMany expects to insert context changes into the target output.  For the second option you have to right click the ID source field and then choose Context -> Part.  Here is a good example of the basics for graphical mapping node functions - Node Functions Tutorial and you can find other in blog posts or by searching Google.

Regards,

Ryan Crosby

former_member182412
Active Contributor
0 Kudos

Hi Adam,

You can use the below mapping also.

Test:

Regards,

Praveen.

0 Kudos

thanks for the help!

Answers (2)

Answers (2)

0 Kudos

Hi Adam,

Kindly refer the below mapping logic.

Hope this works out.

Regards

Baski

former_member182412
Active Contributor
0 Kudos

Hi Bhaskaran,

  • Please dont give the duplicate answers, the ActionE mapping is same as Ryan suggested.
  • And Code is not a constant, it must be mapped from type and fixed values.

Regards,

Praveen.

0 Kudos

Hi Praveen,

I have not referred the answer suggested by Praveen. This is my own solution to the question raised by Adam.

I feel to present the solution in a more elaborate way so that everyone can understand.

Regarding the parameter "Code", Adam hasnt elaborated much on the condition logic. Hence I referred the source and target structure and mapped accordingly.

former_member182412
Active Contributor
0 Kudos

Hi Bhaskaran,

Still it is duplicate answer because Adam latest reply he mentioned he sorted everything except the code mapping.


The only piece it didn't do is add in the attribute.  So I am getting:

<ActionE code="Add">123</ActionE>

<ActionE>abc</ActionE> 

also he mentioned about code mapping.


So I am using FixValues to map that <type> into the attribute "code".  Need the attribute for every instance of <ActionE>

Regards,

Praveen.

Former Member
0 Kudos

Hi Adam,

Raise the context of ID to Data instead of Part.

I hope you know the concept of context handling in SAP PI.

Regards,

Vishal