Skip to Content
avatar image
Former Member

Mapping problem.

Hi.

Have a mapping problem.

The source looks like:

<zmessage>
  <zidocmessage>
    <zidoc>
      <zidocheader>
         <hfield1>hf1</hfield1>
         <hfield2>hf2</hfield2>
         <zidocitem>
           <ifield1>if1</ifield1>
           <ifield2>if2</ifield2>
         </zidocitem>
         <zidocitem>
           <ifield1>if1</ifield1>
           <ifield2>if2</ifield2>
         </zidocitem>
      </zidocheader>
    </idoc>
  <zidocmessage>
    <zidoc>
      <zidocheader>
         <hfield1>hf1</hfield1>
         <hfield2>hf2</hfield2>
         <zidocitem>
           <ifield1>if1</ifield1>
           <ifield2>if2</ifield2>
         </zidocitem>
         <zidocitem>
           <ifield1>if1</ifield1>
           <ifield2>if2</ifield2>
         </zidocitem>
      </zidocheader>
    </idoc>
</zmessage>

And the target should be like:

<zmessage>
  <zfilemessage>
    <zfilefirstrec>
      <firstrecfield1>ff1</firstrecfield1>
      <firstrecfield2>ff2</firstrecfield2>
    </zfilefirstrec>
    <zfileheader>
      <hfield1>hf1</hfield1>
      <hfield2>hf2</hfield2>
    </zfileheader>
    <zfileitem>
       <ifield1>if1</ifield1>
       <ifield2>if2</ifield2>
    </zfileitem>
    <zfileitem>
       <ifield1>if1</ifield1>
       <ifield2>if2</ifield2>
    </zfileitem>
    <zfileheader>
      <hfield1>hf1</hfield1>
      <hfield2>hf2</hfield2>
    </zfileheader>
    <zfileitem>
      <ifield1>if1</ifield1>
      <ifield2>if2</ifield2>
    </zfileitem>
    <zfileitem>
       <ifield1>if1</ifield1>
       <ifield2>if2</ifield2>
    </zfileitem>
  <zfilemessage>
</zmessage>

firstrecfield1 and firstrecfield2 are mapped with constants.

zidocheader -> zfileheader

zidocitem -> zfileitem

When I do the mapping I get 2 entries of zfilefirstrec if I have 2 zidocmessages in the source.

Are there any way for me to make it so I only get 1 zfilefirstrec in the target?

I can't change the structure of the source or the target message.

BR

Kalle

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Sep 01, 2008 at 07:13 AM

    Hi,

    Check below blogs

    Message Mapping Simplified - Part I

    /people/sravya.talanki2/blog/2005/12/08/message-mapping-simplified-150-part-ii

    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/frameset.htm

    New functions in the Graphical Mapping Tool XI 3.0 SP13

    File Content Conversion for Multi Hierarchical Structure

    Message Splitting Using the Graphical Mapping Tool

    Number formatting to handle LARGE Numbers

    Optimizing Lookup's in XI

    Minimize memory usage during Message Mapping when replicating an element

    Mapping Context Changes in XI

    /people/jeyakumar.muthu2/blog/2005/12/19/data-mining-using-apriori-algorithm-in-xi-150-part-ii

    /people/jeyakumar.muthu2/blog/2005/11/23/data-mining-using-apriori-algorithm-in-xi-150-part-i

    /people/jeyakumar.muthu2/blog/2005/12/30/data-mining-using-apriori-algorithm-in-xi-150-part-iii

    Java Mapping to handle flat files in SAP XI

    xpath functions in xslt mapping

    Regards,

    Jayasimha jangam

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 07:20 AM

    Hi,

    Do you want the zfilefirstrec to appear only once in th target irrespective of the source structure then, change the occurance of the zfilefirstrec to 1-1.

    I hope this would work.

    Yuga

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Allready have the 1...1 setting on zfilefirstrec segment. The problem is that it's inside and segment set to 1...unbounded. so for every zidocmessage segment coming from the source there are one zfilefirstrec segment created.

      Thinking of making a UDF that has an global variable that I will count up and when it's larger then 1 I return false and the first time I call the function I return true. Then I could create the segment if the function returs true.

      Is this a good way to solve it?

      //Kalle

  • avatar image
    Former Member
    Sep 01, 2008 at 07:21 AM

    Hi kalle,

    Map the zidocheader element from source side to zfilefirst rec and try to test mapping.As u want the zfirstrec to appear the number of times the idoc appears this might help you out.

    Make the occurance of the zfirstrec field to unbound.

    Thanks,

    Ram.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 01, 2008 at 07:48 AM

    Hi,

    As per your source input apply the below logic.

    hfield1removeContextsSplitByValue(Value Changed)collapseContextszfilemessage

    Constant map to zfileheader.

    hfield1removeContextsSplitByValue(Value Changed)collapseContextshfield1

    hfield2removeContextsSplitByValue(Value Changed)collapseContextshfield2

    zidocitemremoveContextsSplitByValue(Each Value)collapseContextszfileitem

    ifield1--ifield1

    ifield2--ifield2

    Regards,

    Prakasu

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Prakasu.

      I get the following result from your mapping:

      <zmessage>
        <zfilemessage>
          <zfilefirstrec>
            <firstrecfield1>ff1</firstrecfield1>
            <firstrecfield2>ff2</firstrecfield2>
          </zfilefirstrec>
          <zfileheader>
            <hfield1>hf1</hfield1>
            <hfield2>hf2</hfield2>
          </zfileheader>
          <zfileitem>
             <ifield1>if1</ifield1>
             <ifield2>if2</ifield2>
          </zfileitem>
          <zfileitem>
             <ifield1>if1</ifield1>
             <ifield2>if2</ifield2>
          </zfileitem>
        <zfilemessage>
      </zmessage>

  • avatar image
    Former Member
    Sep 01, 2008 at 08:52 AM

    Hi kalle,

    According to your target structure you cont get the value

    zfilemessage

    header

    item

    header

    item.

    If you have a common node for Header and item then,Like below

    zfilemessage

    zfilefirstrec

    Common

    header

    item

    That time it will full fill your requirement.

    Otherwise it will create a target structure like below if you apply the below logic...

    Constant--zfilemessage

    zidocheaderRemove Contextzfileheader

    zidocitemRemove Contextzfileitem

    header and item fields map with simple mapping...

    That time you will get a structure like below..

    zfilemessage

    header

    header

    item

    item

    item

    item.

    Regards,

    Prakasu

    Add comment
    10|10000 characters needed characters exceeded