cancel
Showing results for 
Search instead for 
Did you mean: 

Group records by value

Former Member
0 Kudos

Hi Experts,

Can records be grouped by value?

I'm having the following scenario:

Flat file -> PI -> Idoc

The flat file looks like this:

1001;123456

1001;123457

1001;123458

1002;123459

1002;123460

1003;123461

This maps to the following XML structure:

<record>

     <number>1001</number>

     <value>123456</value>

<record>

<record>

     <number>1001</number>

     <value>123457</value>

</record>

etc.

I want to map the structure into the following(grouped by number):

<record>

     <number>1001</number>

     <value>

          <morevalues>123456</morevalues>

          <morevalues>132457</morevalues>

          <morevalues>123458</morevalues>

     </value>

<record>

Can someone help me with my problem?

Thanks,

Koen

PI 7.1

Accepted Solutions (1)

Accepted Solutions (1)

gagandeep_batra
Active Contributor
0 Kudos

hi schouten

check for following that may help you.

i have checked with dummy

Regards

Gagandeep

Former Member
0 Kudos

Thanks for the help Batra. I've now got the right amount of <vale> and <morevalues> nodes. There's only the wrong value in the nodes of <morevalues>.

My scenario is slightly different then your example above:

result:

<MT_Test2>

     <Record>

          <Empro>

          <vale>

               <morevalues>123</morevalues>

          </vale>

          <vale>

               <morevalues>124</morevalues>

          </vale>

     </Record>

</MT_Test2>

As I said above. I've got the right amount of <vale> records. I've only got the wrong <morevalues> values. Is there a way to get the right values in the <morevalues> nodes? I've tried the example above. But it doesn't work.

I hope the problem is clear enough. It's a little hard to explain the problem.

Answers (2)

Answers (2)

peter_wallner2
Active Contributor
0 Kudos

Hello K.,

You can also do it using XSLT. Is that an option for you? Please let me know.

Best regards,

Peter

gagandeep_batra
Active Contributor
0 Kudos

you can handle this in mapping also.

you can use function remove context and splitbyvalue( value change) to achieve this

Former Member
0 Kudos

Ok, but how do I use these node functions? Is there a example scenario available on the SCN?

Former Member
0 Kudos

might be below logic helpful for ur req:

number -> remove contect -> splitByValue (value change) -> target field

for ex : u refer below print screens:

or

Former Member
0 Kudos

Thanks Sankar,

I've got the right number of <record> nodes. But now the following:

how do I get all the <value> records that belong to the same record? If I use the above solution, I only get one record, not all of them.