cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping problem.

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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>

former_member750652
Contributor
0 Kudos

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.

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

Check below blogs

/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

/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

Regards,

Jayasimha jangam