cancel
Showing results for 
Search instead for 
Did you mean: 

Message Sorting - Mapping Flat Structure to Hierarchial Structure

Former Member
0 Kudos

Hello,

I am having some issues with mapping from a flat structure to an Idoc. Here is the source message

<SourceMessageType>
   <Record>
      <Level>
         <LvlSeqID>1</LvlSeqID>
      </Level>
      <Level>
         <LvlSeqID>2</LvlSeqID>
      </Level>
      <Element>
         <LvlSeqID2>1</LvlSeqID2>
         <ElmSeqID>A</ElmSeqID>
      </Element>
      <Element>
         <LvlSeqID2>2</LvlSeqID2>
         <ElmSeqID>A</ElmSeqID>
      </Element>      
   </Record>
</SourceMessageType>

<TargetMessageType>
   <IDOC>
      <Level>
         <LvlSeqID>1</LvlSeqID>
         <Element>
            <LvlSeqID2>1</LvlSeqID2>
            <ElmSeqID>A</ElmSeqID>
         </Element>
      </Level>
      <Level>
         <LvlSeqID>2</LvlSeqID>
         <Element>
            <LvlSeqID2>2</LvlSeqID2>
            <ElmSeqID>A</ElmSeqID>
         </Element>
      </Level>
   </IDOC>
</TargetMessageType>

Both <Level> and <Element> are unbounded nodes and arrive unsorted. The <Level> node has a Sequnece ID (LvlSeqID) and the <Element> node has a corresponding Sequence ID (LvlSeqID2), and in the target structure, the matching <Element> nodes should be under the <Level> node. There may be any number of <Element> nodes for 1 <Level> node. I have tried to use the Graphical Mapping Tool to do this, but it does not seem to work as I would have liked. The next thing I am going to try is to use a User Defined Function.

Can you suggest anything else?

Thanks

Zeshan

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ,

Please check the Mapping examples on help.sap.com.

You can first sort the nodes Level and Element based on Ids.

For creating the Level nodes = no. of Element Nodes, the function UseOneAsMany can be used.

Regards,

Beena.