cancel
Showing results for 
Search instead for 
Did you mean: 

mapping problem

former_member440449
Participant
0 Kudos

Hi Gurus,

I have this source structure from a file:

<SEG>
  <field1>1</field1>
  <field2>abc</field2>
  <field3>abc</field3>
</SEG>
<SEG>
  <field1>1</field1>
  <field2>def</field2>
  <field3>def</field3>
</SEG>
<SEG>
  <field1>2</field1>
  <field2>ghi</field2>
  <field3>ghi</field3>
</SEG>

And what I need in my target structure is to create 1 IDoc per same field1 value. In this example, I will beed 2 IDocs, where 1 contains the first 2 <SEG> and the other one the last <SEG>.

Target structure may be like this:

<IDoc>(0..unbounded)
   <SEG1>(1..1)
      <value1>1</value1>
      <anotherSEG1>(0..unbounded)
         <value2>abc</value2>
         <value3>abc</value3>
      </anotherSEG1>
      <anotherSEG1>(0..unbounded)
         <value2>def</value2>
         <value3>def</value3>
      <anotherSEG1>
   </SEG1>
</IDoc>
<IDoc>(0..unbounded)
   <SEG1>(1..1)
      <value1>2</value1>
      <anotherSEG1>(0..unbounded)
         <value2>ghi</value2>
         <value3>ghi</value3>
      </anotherSEG1>
   </SEG1>
</IDoc>

Can this be possible without UDF?

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

chk this:



field1--remove context--sort---splitby value(value change)---collapse context---idoc



field1--remove context--sort---splitby value(value change)---collapse context--splitby value(each value)---SEG1



field1--remove context--sort---splitby value(value change)---collapse context--splitby value(each value)---value1



field1--remove context--sort---splitby value(value change)-----anotherSEG1



field1--remove context---
          --sortby key- ------------------- --formatByexample----splitby value(each value)-----value2
filed2--removecontext---                              /
                                                    /
field1--remove context--sort---splitby value(value change)-----

rajasekhar_reddy14
Active Contributor
0 Kudos

try mapping for SEG1 like below.

SEG--->removecontext--->
                                                                                ------------>formatbyexample---->SEG1
   Field1--->removecontext--->sort--->splitbyvalue(valuechange)----->

Former Member
0 Kudos

HI Chapa,

yes,

As my friends have suggested you can use the Node Functions without using the UDF.

But the problem is you should be careful of all the target fields as they should also have the same context in which you are generating the Idoc Parent Node.

I have done similar stuff 2 years back.

For the child Nodes of Idoc, if you are able to generate them in context of the Idoc its fine or else you may have to write uDF for these.

Take the Input field A -->Remove Contexts --> Sort > splitByValue(ValueChanged)>Collapsecontext--> Idoc

This will perfectly remove all the duplicated and will generate 1 Idoc per Field A ignoring Duplicates.

But now the other child fields of Idoc they just go to target in Queue.You cannot sort them.

So, Just take care of the context for the child nodes.

Thanks,

VK

rajasekhar_reddy14
Active Contributor
0 Kudos

Field1->removecontext->sort->splitbyvalue(value change)->collapsecontext--->IDoc.

above logic will genarate multiple idocs if Field1 value changes.

similar way try for another segment too..

former_member191435
Contributor
0 Kudos

Hi Chapa,

U can create 2 IDOCs using Graphical Mapping also.

take field1 with context higher lever and use splitbyvalue change then assign to the target IDOC.

Thanks,

Enivas

MichalKrawczyk
Active Contributor
0 Kudos

Hi,

>>>Can this be possible without UDF?

I don't think so - you need to write a UDF to be able to create correct idocs from correct structures

Regards,

Michal Krawczyk