cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping challenge in record grouping

Former Member
0 Kudos

I am facing a challenge in a scenario that involves mapping an incoming flat text (invoice list) to a target XML structure. The source is JMS queue, so I have used JMS sender channel and specified the standard content conversion parameters in 'modules' tab. Here are details -

Source flat text format:

IVH|<some pipe separated fields>

IVD|<some pipe separated fields>

SHP|<some pipe separated fields>

IVH|<some pipe separated fields>

IVD|<some pipe separated fields>

IVD|<some pipe separated fields>

SHP|<some pipe separated fields>

IVH|<some pipe separated fields>

IVD|<some pipe separated fields>

SHP|<some pipe separated fields>

IVD|<some pipe separated fields>

SHP|<some pipe separated fields>

SHP|<some pipe separated fields>

As you can see, the text is a list of invoices such that each invoice contains 3 types of records - IVH (1..1), IVD (1..n) and SHP (1..n). In each invoice, IVH is always the first record and occurs only once, but the sequence of IVD and SHP thereafter can vary.

Content conversion in JMS sender is correctly converting above text into corresponding XML structure with various nodes appearing in same order (and at same level) as above. So the source XML looks like -

<MT_Invoice>

     <Recordset>

          <IVH>

          <IVD>

          <SHP>

          .......

          .......

          <SHP>

     </Recordset>

</MT_Invoice>

Required target XML structure:

It's required to collect all IVD and SHP nodes immediately following a particular IVH node, but preceding the next IVH node. And unfortunately, there are no common identifiers among IVH, IVD and SHP which can be used to link them together. So the target XML should look like -

<IVH>

    <IVD/>

    <SHP/>

</IVH>

<IVH>

    <IVD/>

    <IVD/>

    <SHP/>

</IVH>

<IVH>

    <IVD/>

    <SHP/>

    <IVD/>

    <SHP/>

    <SHP/>

</IVH>

I have been trying the XSLT mapping with "following-sibling" clause, but not able to generate target XML fully. Does anyone have any idea here ? Let me know also know if this can be achieved in graphical mapping. Thanks!

Regards,

-Shankar

Accepted Solutions (1)

Accepted Solutions (1)

gagandeep_batra
Active Contributor
0 Kudos

Hi  Shankar,

you can use java udf for your requirement......

using this you can achieve your requirement....

Regards,

Gagan

Former Member
0 Kudos

Thanks.. I think that's the last option.

Regards,

-Shankar

Answers (1)

Answers (1)

sunilchandra007
Active Contributor
0 Kudos

Did you check http://scn.sap.com/community/pi-and-soa-middleware/blog/2010/01/14/file-conversion-using-nodeception . It discuss similar problem.

Regards,

Sunil Chandra

Former Member
0 Kudos

Thanks Sunil for the link.. Unfortunately, that blog doesn't exactly address my problem, since in my case, the order and occurrence of IVD and SHP nodes are dynamic.

Regards,

-Shankar