Skip to Content
0
Former Member
Sep 07, 2007 at 06:30 AM

Tuning the file adapter to parse subnodes

17 Views

I have been looking for a solution, that how to handle Hierarchies in receiver file content conversion but everyone's suggestion is to make it as flat structure, were subnodes cant be handled by File Adapter. But in my case, I should handle the hierarchies. So I traced the File adapter behaviour and now I'm able to achieve it in my case.

My source data will be as follows,

<Root>

<Lineitem>

<no>101</no>

<name>pen</name>

<Comment>

<color>red</color>

<price>20</price>

</Comment>

<Comment>

<color>blu</color>

<price>50</price>

</Comment>

</LineItem>

</Root>

My Receiver FCC parameters are

LineItem.fieldFixedLengths = 3,3

LineItem.absoluteRowWidth = 6

Comment.fieldFixedLength = 3,2,3,2

Comment.endSeparator = 'nl'

Output:

101pen

red20

blu50

The reason I used 3,2,3,2 for Comment.fieldFixedLengths though it has only 2 fields because the parser considers the 'comment' as a field of 'lineitem' but for the 'comment' I had specified 'fieldFixedLength' parameters so it gets the fieldlength of 3rd field and omits the first two were it already passed.But for the other occurrances it going to take first two field lengths.

The absolute row width is to make the subnode to be on next line.

Though I achieved my need through this method, it has some drawbacks like

>The number of elements in parent node must be greater or equal to child node.

>Applicable only for fixedlength files.

>wont applicable if it has more then two levels

It works well, with many occurrences of both lineitem and comment.

I would like to receive the suggestions, since its not SAP recommended method.

<<<soon to be blog'd in detail>>>