cancel
Showing results for 
Search instead for 
Did you mean: 

How to nest a not secuencial flat file using FCC

Former Member
0 Kudos

Hi gurus, I have to convert a flat file in not a secuencial order into a deep nest xml file

the input file after FCC is as follow

<Recordset>

     <Header>

          <Value1>H1</Value1>

          <Value2>H2</Value2>

     </Header>

     <HeaderPed>         

          <Value1>1</Value1>

          <Value2>2</Value2>

     </HeaderPed>

     <DetailsPed>         

          <Value1>D1</Value1>

          <Value2>D2</Value2>

     </DetailsPed>    

     <HeaderPed>         

          <Value1>3</Value1>

          <Value2>4</Value2>

     </HeaderPed>

     <DetailsPed>         

          <Value1>D3</Value1>

          <Value2>D4</Value2>

     </DetailsPed>

     <DetailsPed>         

          <Value1>D5</Value1>

          <Value2>D6</Value2>

     </DetailsPed>    

     <DetailsPed>         

          <Value1>D7</Value1>

          <Value2>D8</Value2>

     </DetailsPed>

     <Footer>         

          <Value1>1</Value1>

          <Value2>2</Value2>

     </Footer>

</Recordset>


The output file most be generate as follow:


<Recordset>

     <Header>

          <Value1>H1</Value1>

          <Value2>H2</Value2>

     </Header>

     <HeaderPed>         

          <Value1>1</Value1>

          <Value2>2</Value2>         

          <DetailsPed>         

               <Value1>D1</Value1>

               <Value2>D2</Value2>

          </DetailsPed>

     </HeaderPed>         

     <HeaderPed>         

          <Value1>3</Value1>

          <Value2>4</Value2>         

          <DetailsPed>         

               <Value1>D3</Value1>

               <Value2>D4</Value2>

          </DetailsPed>

          <DetailsPed>         

               <Value1>D5</Value1>

               <Value2>D6</Value2>

          </DetailsPed>    

          <DetailsPed>         

               <Value1>D7</Value1>

               <Value2>D8</Value2>

          </DetailsPed>

     </HeaderPed>    

     <Footer>         

          <Value1>1</Value1>

          <Value2>2</Value2>

     </Footer>

</Recordset>


That's it, each <DetailsPed> Node in its corresponding <HeaderPed> Node.


Thanks

Accepted Solutions (1)

Accepted Solutions (1)

former_member182412
Active Contributor
0 Kudos

Hi Hector,

Check my blog below for this exact same requirement. You need to use FCC as per the blog then Header and Detail nodes will come in different context instead of same context.

Similar thread which i explained how it works.

Regards,

Praveen.

Former Member
0 Kudos

Thanks Praven for you reply.

I try you recommendation but the mapping throw an exception

My sender file is as follow

My Sender File Adapter is as follow (FCC Section)

former_member182412
Active Contributor
0 Kudos

Hi Hector,

You can do the FCC and mapping like below.

FCC:

Target nodes Header, HeaderPed and Footer mapping just field to field mapping but you just need to change the source node context to root node like below.

Mapping for DetailsPed segment:

Mapping Result:

Regards,

Praveen.

Former Member
0 Kudos

Thanks Praveen...

The issues was the definition on the FCC, i put like you told me, and works fine.

Answers (2)

Answers (2)

engswee
Active Contributor
0 Kudos

Hi Hector

If there is a field in HeaderPed with a matching value to a field in DetailsPed, then you can use XSLT to deepened the XML. More details in my article below.

Alternatively, you can opt for a custom adapter module that I have developed specifically to tackle FCC for deep structures. Check it out below:-

Rgds

Eng Swee

justin_santhanam
Active Contributor
0 Kudos

Hello Hector,

I believe the XML is sample. But in your actual data do you know if each HeaderPed has any indication of how many DetailPed each of them has?

Like in your example 1st HeaderPed should say there is 1 DetailPed, 2nd HeaderPed should say there is 3 DetailPed. Not sure if you have it, then it makes the mapping more easier.

Thanks!

Former Member
0 Kudos

Hi Justin, thanks for you reply,

Yes, that XML is an example, but the structure is similar. No, there isnt any indicator in each HeaderPed that indicate how many DetailsPed has it.