cancel
Showing results for 
Search instead for 
Did you mean: 

Message mapping issue

former_member684393
Discoverer
0 Kudos

Dear All,

     I am a freshman on PI (SAP also) and currently working on a Scenario which will import data from a xml to ERP. The xml file format is as the following:

     <Data>

          <Row>

               <Header>

                    <field1>value 1</field1>

                    <field2>value 2</field2>

               </Header>

               <Item>

                    <fielda>test a1</fielda>

                    <fieldb>test b1</fieldb>

                    <fieldc>test c1</fieldc>

                    <fieldd>test d1</fieldd>

                    <fielde>test e1</fielde>

                    <fieldf>test f1</fieldf>

                    <fieldg>test g1</fieldg>

               </Item>

               <item>

                    <fielda>test a2</fielda>

                    <fieldb>test b2</fieldb>

                    <fieldc>test c2</fieldc>

                    <fieldd>test d2</fieldd>

                    <fielde>test e2</fielde>

                    <fieldf>test f2</fieldf>

                    <fieldg>test g2</fieldg>

               </item>

          </Row>

          <Row>

               <Header>

          ........

          ........

          ........

          </Row>

     </Data>

     Field 1 and 2 in <Header> are the key for each <Item> in the same <Row>.

     The Data will be imported to a flat table with the following structure:

          [field1],[field2],[fielda],[fieldb],[fieldc],[fieldd],[fielde],[fieldf],[fieldg]

     Since there is only 1 <Header> but have n <Item> in each row, How can I do the message mapping which can make the imported record like this:

                              [field1],[field2],[fielda],[fieldb],[fieldc],[fieldd],[fielde],[fieldf],[fieldg]

                      value 1, value 2,test a1, test b1, test c1, test d1, test e1, test f1, test g1

                      value 1, value 2,test a2, test b2, test c2, test d2, test e2, test f2, test g2

     Limitation: The source xml file is provided from outsider which the format cannot be changed.

Thanks,

Andy

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

Hi Andy,

Check this pictures:

With the root's context you will have so much target item as source item:

Now you create so much field1 (field2 is the same) for target field 1, and it's neccesary to split by each value because you have different target context (target item context):

The other nodes you can assign directly:

Finally you can check with this example:

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

<Data>

   <Row>

      <Header>

         <field1>a</field1>

         <field2>b</field2>

      </Header>

      <Item>

         <fielda>1</fielda>

         <fieldb>2</fieldb>

         <fieldc>3</fieldc>

         <fieldd>4</fieldd>

         <fielde>5</fielde>

         <fieldf>6</fieldf>

         <fieldg>7</fieldg>

      </Item>

      <Item>

         <fielda>21</fielda>

         <fieldb>22</fieldb>

         <fieldc>23</fieldc>

         <fieldd>24</fieldd>

         <fielde>25</fielde>

         <fieldf>26</fieldf>

         <fieldg>27</fieldg>

      </Item>

   </Row>

   <Row>

      <Header>

         <field1>c</field1>

         <field2>d</field2>

      </Header>

      <Item>

         <fielda>1</fielda>

         <fieldb>2</fieldb>

         <fieldc>3</fieldc>

         <fieldd>4</fieldd>

         <fielde>5</fielde>

         <fieldf>6</fieldf>

         <fieldg>7</fieldg>

      </Item>

   </Row>

</Data>

If we check the queues:

And in the test tab:

Regards and good luck, welcome to the PI world.

former_member684393
Discoverer
0 Kudos

Dear Iñaki,

     I just found that the xml file may have none <item>. How can I handle this case?

Regards,

Andy

Former Member
0 Kudos

once you have to check below funcyion mightbe helpful

you need if those values , then mapp mapwithdefault after Item ...

iaki_vila
Active Contributor
0 Kudos

Hi Andy,

Try with the Sankar solution:

Item with Row context and mapWithDefault with a blank character.

Regards.

Answers (3)

Answers (3)

Former Member
0 Kudos

yes earlier poster is correct , that is only one possiable by using "useOneAsMany" node function.

field1(h) ->item -> fielda(item level) -> useOneAsMany -> target field

santosh_k3
Active Participant
0 Kudos

Hi Andy,

Use UseoneAsManyNode Node function.

this is clearly explained in the below link.

http://www.saptechnical.com/Tutorials/XI/NodeFunctions/Page5.

Let us know if you find any difficulties

Thanks

Sai

Former Member
0 Kudos