Focal Point
[SOLVED]Transform looping

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/9537085036

May 03, 2013, 03:35 PM
Charles Maheu
[SOLVED]Transform looping
Hi,

I need to create a transform that has an input like this:
<Order>
  <OrderHeader>
    <Customer>1234</Customer>
  </OrderHeader>

  <OrderDetail>
    <Line>10</Line>
    <Product>4321</Product>
  <OrderDetail>

  <OrderDetail>
    <Line>20</Line>
    <Product>9876</Product>
  <OrderDetail>

  <OrderWeight>
    <Line>10</Line>
    <Weight>324.45</Weight>
    <WeightUOM>KG</WeightUOM>
  </OrderWeight>

  <OrderWeight>
    <Line>20</Line>
    <Weight>134.45</Weight>
    <WeightUOM>KG</WeightUOM>
  </OrderWeight>
  
</Order>


The problem is that I need in my output to merge the OrderDetail and OrderWeight to get something like this:
<Order>
  <OrderHeader>
    <Customer>1234</Customer>
  </OrderHeader>

  <OrderDetail>
    <Line>10</Line>
    <Product>4321</Product>
     <Weight>324.45</Weight>
    <WeightUOM>KG</WeightUOM>
  <OrderDetail>

  <OrderDetail>
    <Line>20</Line>
    <Product>9876</Product>
    <Weight>134.45</Weight>
    <WeightUOM>KG</WeightUOM>
  <OrderDetail>
 
</Order>


By creating Groups with filters, I managed to get the good values, but the problem is that only the last OrderDetail has the value assigned. I get something like this:
  <OrderDetail>
    <Line>10</Line>
    <Product>4321</Product>
    <Weight/>
    <WeightUOM/>
  <OrderDetail>

  <OrderDetail>
    <Line>20</Line>
    <Product>9876</Product>
    <Weight>134.45</Weight>
    <WeightUOM>KG</WeightUOM>
  <OrderDetail>


Does anybody has an idea what could be wrong? Is it possible to loop through element that are outside the current loop?

This message has been edited. Last edited by: Charles Maheu,


WebFocus 7.6.8
OS: Windows
iWay: 6.1.4
May 03, 2013, 04:43 PM
Doug
I'd use nested loops in WebFOCUS DM... Where are you doing THIS?
May 06, 2013, 08:24 AM
Charles Maheu
iWay Transformer.

Nested loop gives me the result described in my original post.

Regards,
Charles


WebFocus 7.6.8
OS: Windows
iWay: 6.1.4
May 07, 2013, 05:03 AM
Paul_Maitland
Which version of iway transformer are you using - Just ran your input on ism 6.1.7 and got you required output. Let me know if you need the GXP.


iSM 6.1.6
iDM 7.7.4
Windows 2008 R2
May 07, 2013, 08:09 AM
Charles Maheu
I'm using 6.1.4 and yes i'd like to see that gxp if possible.

Regards,
Charles


WebFocus 7.6.8
OS: Windows
iWay: 6.1.4
May 07, 2013, 12:01 PM
Charles Maheu
Ok I got it working.

I'm not sure if it's the better way, but it worked.

What I did is that concatenate my line number with the value using seperator before the main loop.

Then in the loop using the line number I can get the substring of my value.

Like I said it's not clean, but it worked.

Thanks for your help.

Paul_Maitland: If you could still provide me your GXP, i'd like to see your solution.

Regards,
Charles


WebFocus 7.6.8
OS: Windows
iWay: 6.1.4