Fixed Length Flat File

Hi Everyone,

I need to parse a fixed lenght flat file. The hirerarcy is as follows
+File Header

++Batch Header-1 [Multiple]
+++Detail Record [0]
++++AddRecord -3
++++AddRecord -2
++++AddRecord -3
+++Detail Record [1]
++++AddRecord -2
++++AddRecord -2
++++AddRecord -3
++++AddRecord -3
++++AddRecord -3

++Batch Trailer

[COLOR=#009900]++Batch Header-1
+++Detail Record [0]
++++AddRecord -1
+++Detail Record [1]
++++AddRecord -1
++++AddRecord -3

[/COLOR]
++Batch Trailer

+File Trailer

::>The AddRecord record starts with ‘8’ followed by ‘01’,‘02’,‘03’ indicating the versions , ie records starts with 801 / 802 /803.
::> I have cretaed the FF Dict and schema having record identifier as 801,802,803 and these records are unordered. So what is haapenning is everytime 801/802/803 is occuring it is creating a new list ex -

+++Detail Record [0]
++++AddRecord 3 [0]
++++AddRecord 2 [0]
++++AddRecord 3 [0] X

Expected : -
+++Detail Record [0]
++++8[0]
+++++AddRecord 3 [0]
++++8[1]
+++++AddRecord 2 [0]
++++8[2]
+++++AddRecord 3 [0]


How this can be acheived ::slight_smile:

Thanks in advance

Jason

i think it would be really helpful to give u solution if u can attach a example flatfile which u got …becouse idk if anyone understood the heirarchy u explined in the post,i did not ! ,so can u attach your example flatfile …
Sri

Hi,

File hirerarchy and occurrence as follows :-

All records are fixed lenght = 80

+Header [Occurrence Single, Record Identifier ‘00’ ]
++Batch Header [Occurrence multiple, Record Identifier ‘1’ ]
+++Detail Record [Occurrence multiple, Record Identifier ‘7’ ]
++++ADD RECORD -1 [Occurrence multiple, Record Identifier ‘801’ ]
++++ADD RECORD -2 [Occurrence multiple, Record Identifier ‘813’ ]
++++ADD RECORD -3 [Occurrence multiple, Record Identifier ‘815’ ]
+++Batch Trailer [Occurrence single, Record Identifier ‘90’ ]
+File Trailer [Occurrence single, Record Identifier ‘9’ ]

ADD RECORD -1 /2/3 are unordered and can occur multiple times

If all are ordered then parsing is fine. As it is unordered the list items is getting created multiple times. Attached is the FF please someone look into this .

Jason
sampleFile.txt (1.44 KB)
ScreenShot.JPG

can u just clarify one thing …does the records(1,7,2) alwyas be in this order …i mean when we just consider these three records …(not 815,801 and 813) …
what i see in ur sample file is
1
7
2
7
2
is this consistent for all batch records …and in between first 7 and first 2 u can have any occurance of 815 ,801 and 813 in any order …
is this right …
sri

Hi Sri,

ya that is another problem similar one.

Under 1 we can have unordered 7 and 2 rec example

+1 [ Detail Record 0 ]
++7 [SAy 3 items 0,1,2]
++2 [SAy 3 items 0,1,2]
++7 [SAy 3 items 0,1,2]
++2 [SAy 3 items 0,1,2]

Whenver the record types are changing in data another list is appearing. All the 7 and 2 will come under the one detail record - 1. Here

In the screen shot u will see that multiple lists of 7 and 2 are occurring so will not be able to loop over as it is indefinite.

Please suggest anything which will help to parse the data .

Jason

Hi,
Why don’t you have the following pattern

+1
++7
+++8
+++2
+++9

male the 8,2,9 unlimited unchecking the mandatory for those records. Also 7 should be mandatory and unlimited.Even 1 is mandatory and unlimited. try this and let us know

Rgds,
Pradeep

Hi Pradeep,

The records 7/2 is already unlimited. I donot have record type as ‘8’ , what I have is ‘801’ ‘813’ and ‘815’. You will see in the screenshot that even that under the header record multiple list of 7 and 2 are occuring in an indefinite way (Both are unlimited and unordered under the batch header.)

When few record of 7 are coming they are grouped together and when 2 records are coming in data they are grouped together. Now if 7 record sets are coming again then another list is getting created of 7 and so on…

Jason:confused:

This hierarchy as Pradeep mentioned should also work,as per your ff data if you understood correctly,

+1(maxRepeat=unlimited) Header
++7(unlimited)
+++8(unlimited)
+++2(single)
+++9(unlimited)–Trailer

Is this structure causing problems while parsing/breaking??

HTH,
RMg

Hi rmg,

I was keenly waitng for u to reply. Yeah the structure used by me is as follows , slight change in what is mentioned by you : -

+1(maxRepeat=unlimited) Batch Header
++7(unlimited) Detail Record
+++801(unlimited) [ Different Fields ,01 version , Record identf ‘801’]
+++813(unlimited) [ Different Fields, 13 version , Record identf ‘813’ ]
+++815(unlimited) [ Different Fields , 15 version, , Record identf ‘815’ ]
+++2(unlimited)
+++9(Single)–Trailer for each Batch record

After parsing I am getting : -

+1([0]) Header
++7(List - Say 4 items)
+++2(List - Say 3 items)
++7(List)
+++2(List)
++7(List)
+++2(List)

Under a Batch record 1 -> multiple lists of detail record 7 and 2 are coming as the data in the flat file is unordered. Please suggest something

jason

hi , this is what i think the structure should be …
header ( single)
—Batch Header( multiple)
-----Detail record 7(multiple times)
--------801(multi)
--------803(multi)
--------815(multi)
--------detail record 2 (single)
--------Batch Trailor (single)
trailor(single)

the only thing concerns me is the combinations of 801 ,803 and 815 which can occur in detail record …so maybe u have to check different combinations and place them accordingly… make all the 801,803 ,815 and batch trailor records not required
HTH
sri

Jason,

Comments above suggested by Srikanth if you have setup your FFSchema that way it should parse successfully.Can you check regarding 800 loops thing as said.Please try and let us know.

HTH,
RMG