cancel
Showing results for 
Search instead for 
Did you mean: 

Context handling - Graphical Mapping

RafaelVieira
Active Participant
0 Kudos

Hi,

I have the following source structure, trying to map to the target structure below. It's a 1:N mapping.

I'm using graphical mapping with context handling but it's being hard to define the best approach to achieve this mapping since for each new document (docnum) I have to create a new text file in the target system (new MT).

Does anyone have a suggestion of which would be the best approach to do this mapping?

Source

<MT_Source>

  <XML_EXT2>

    <item>

       <DOCNUM>0000090146</DOCNUM>

       <FIELD>VERSION</FIELD>

       <VALUE>2.00</VALUE>

    </item>

    <item>

       <DOCNUM>0000090146</DOCNUM>

       <FIELD>ID</FIELD>

       <VALUE>11111</VALUE>

    </item>

    <item>

       <DOCNUM>0000090146</DOCNUM>

       <FIELD>XSERV</FIELD>

       <VALUE>SKIP</VALUE>

    </item>

    <item>

       <DOCNUM>0000090222</DOCNUM>

       <FIELD>VERSION</FIELD>

       <VALUE>2.00</VALUE>

    </item>

    <item>

       <DOCNUM>0000090222</DOCNUM>

       <FIELD>ID</FIELD>

       <VALUE>22222</VALUE>

    </item>

    <item>

       <DOCNUM>0000090222</DOCNUM>

       <FIELD>XSERV</FIELD>

       <VALUE>SKIP</VALUE>

    </item>

    <item>

       <DOCNUM>0000090333</DOCNUM>

       <FIELD>VERSION</FIELD>

       <VALUE>2.00</VALUE>

    </item>

    <item>

       <DOCNUM>0000090333</DOCNUM>

       <FIELD>ID</FIELD>

       <VALUE>33333</VALUE>

    </item>

    <item>

       <DOCNUM>0000090333</DOCNUM>

       <FIELD>XSERV</FIELD>

       <VALUE>SKIP</VALUE>

    </item>

  </XML_EXT2>

</MT_Source>

Target

<Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">

   <Message1>

      <MT_Destination>

          <DOCNUM>0000090146</DOCNUM>

          <VERSION>2.0</VERSION>

          <ID>11111</ID>

          <XSERV>SKIP</XSERV>

      </MT_Destination>

      <MT_Destination>

          <DOCNUM>0000090222</DOCNUM>

          <VERSION>2.0</VERSION>

          <ID>22222</ID>

          <XSERV>SKIP</XSERV>

      </MT_Destination>

      <MT_Destination>

          <DOCNUM>0000090333</DOCNUM>

          <VERSION>2.0</VERSION>

          <ID>33333</ID>

          <XSERV>SKIP</XSERV>

      </MT_Destination>

   </Message1>

</Messages>

Tks!

Accepted Solutions (1)

Accepted Solutions (1)

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi ,

Make sure that  <MT_Destination> occurence 1 to unbounded

and map like this..

<DOCNUM>--->remove context------>splitby value(value change)----->collapsecontext</MT_Destination>

check below link

http://scn.sap.com/thread/3173676

Regards,

Raj

RafaelVieira
Active Participant
0 Kudos

Raja, good content in your answer, however the question is not only in how to create multiple MT target structures. The main question is how to take several source structures and fields and convert them into single structures in target.

If you see the source and target XML's I provided in my question, you will notice that source structure stands for field description where I have to collect them and transform into 1 field in target.

Here goes another sample of how source structure is and what is the desired target structure:

<Messages>

          <Messages1>

                      <MT_Source>

                              <recordset>

                                        <DocNum>11</DocNum>

                                        <Name>ID</Name>

                                        <Value>10001</Value>

                                        <Version>1</Version>

                              </recordset>

                              <recordset>

                                        <DocNum>11</DocNum>

                                        <Name>Date</Name>

                                        <Value>05282012</Value>

                                        <Version>1</Version>

                              </recordset>

                              <recordset>

                                        <DocNum>11</DocNum>

                                        <Name>CreatedBy</Name>

                                        <Value>Myself</Value>

                                        <Version>1</Version>

                              </recordset>

                              <recordset>

                                        <DocNum>22</DocNum>

                                        <Name>ID</Name>

                                        <Value>10002</Value>

                                        <Version>1</Version>

                              </recordset>

                              <recordset>

                                        <DocNum>22</DocNum>

                                        <Name>Date</Name>

                                        <Value>05282012</Value>

                                        <Version>1</Version>

                              </recordset>

                              <recordset>

                                        <DocNum>22</DocNum>

                                        <Name>CreatedBy</Name>

                                        <Value>Himself</Value>

                                        <Version>1</Version>

                              </recordset>

                    </MT_Source>

          </Messages1>

</Messages>

Desired target structure:

<Messages>

          <Messages1>

                    <MT_Target>

                              <DocNum>11</DocNum>     //Present in all recordset from source structure

                              <ID>10001</ID>                     //1st recordset from source

                              <Date>05282012</Date>    //2nd recordset from source

                              <CreatedBy>Myself<CreatedBy>     //3rd recordset from source

                    </MT_Target>

                    <MT_Target>

                              <DocNum>22</DocNum> //Present in all recordset from source structure

                              <ID>10002</ID>                         //4th recordset from source

                              <Date>05282012</Date>        //5th recordset from source

                              <CreatedBy>Himself<CreatedBy>     //6th recordset from source

                   </MT_Target>

          </Messages1>

</Messages>

The multi-MT target structures are being created accordingly, but the fields DocNum, ID, Date, CreatedBy are getting lost with the context changes and I'm not sure if it's possible to achieve just by using graphical mapping objects or not.

Appreciate any suggestion

RafaelVieira
Active Participant
0 Kudos

Solved with a Java UDF.

Tks for your help.

Rafael.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

In addition to Raja's suggestion, below wiki can help u in building your scenario:

http://wiki.sdn.sap.com/wiki/display/NWTech/One+IDOC+to+Multiple+Files+sending+to+Multiple+folders+o...)

Thanks

Amit Srivastava

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can also refer below wiki to understand how removecontext, collapsecontexts and splitbyvalue functions work. Raja pointed out the above logic. If you want to know the functionality of each above functions you can see this link

http://wiki.sdn.sap.com/wiki/display/XI/Explain+node+functions