Flat File Processing| Parent Child Relationship

Hi All,

We have a requirement to process a complex flat file.

Flat file will have larger number of records in a parent child relationship depicted below:

0001|abc|def… Parent Record.
0001|abc|def…Parent Record
0002|abc|def…Child Record
0001|abc|def…Parent Record
0002|abc|def…Child Record
0003|abc|def…Child Record

The record starts with 0001 is the parent record and all the below records will be its child record until it encounters another 0001 record.

Our requirement is publish all the parent and child records together like:

0001|abc|def…
one doc will be publish containing only this record.

0001|abc|def…Parent Record
0002|abc|def…Child Record
One doc will be published containing these two records.

0001|abc|def…Parent Record
0002|abc|def…Child Record
0003|abc|def…Child Record
One doc will be published containing these three records.

Basically in total only 3 docs will be published .

Please let us know how we can implement this in wm 6.5

Thanks,
Amit

Does the parent and child records have same number of fields? If so, a generic dict/schema will convert this data to an IS document, and using the flow logic, u can determine each group that can be published to broker.

-Senthil

Hi Senthil,

Thx for response. Ya all the aprent child has same number of fields.

Also apart from creating the dic/schema, We have done below steps:

  1. Convert the flat file to string
  2. then convert the string to string list and then loop over the string list then using the flow logic we are segregating the records according to parent child relationships.

Please provide your thoughts over this…

Thanks,
Amit

You are getting flatfile as your input right? Why do you parse it to IS doc, and then again convert it to string/string list?

The records seems to have record identifier. convertToValues service displays records in IS doc format after parsing. In this doc, you can see a string called ‘record-id’ which will hold the value of identifier. You can loop over IS doc (ffvalues) directly and perform some logic i believe.

-Senthil

0001|abc|def|Parent Record1
0001|abc|def|Parent Record2
0002|abc|def|Child Record2
0001|abc|def|Parent Record3
0002|abc|def|Child Record3
0003|abc|def|Child Record31

you can make record definition like this:

0001(Parent Record Def)
. – first Field
. – second Field
. —Third Field

…0002(Clild Record Def)
– first Field
– second Field
—Third Field

…0003(Clild Record Def)
– first Field
– second Field
—Third Field

and in Flow service :

–Get the file
–Repeat loop
– convertTovalue(set iterate true )
—Do maping
—Publish doc
—Branch (check FFiterator=null then Exit from loop)

it will work as you mention above:

" First doc contain the details of this
0001|abc|def…
one doc will be publish containing only this record.

second doc contain the details of this
0001|abc|def…Parent Record
0002|abc|def…Child Record
One doc will be published containing these two records.

and Third doc contain the details of this

0001|abc|def…Parent Record
0002|abc|def…Child Record
0003|abc|def…Child Record
One doc will be published containing these three records.

Basically in total only 3 docs will be published ."

Regards
Mukesh