Hi All, Need an urgent help on the following flatfile issue.
As per my requirement, I am trying to process a fixed length flat file along with field separator as ‘|’ and record separator as ‘new line’. I have created the schema and it is parsing all the values as a single string(like 111222333444).
I try to explain with the example:
First Record Field1: Value=111, length=3; Field2: Value=222, length=3; Field3: Value=33, length=3; Field4: Value=444, length=3; Output record length required=12
So my output file looks like: 11122233 444Rec2rec3rec4…
Excepted output: 111|222|33 |444 Rec1(separated fields by ‘|’ delimeter) Rec2 Rec3 Rec4 . . . Please let me know is there a way to define this in schema?
In fixed length flatfile, record length is required… In this case, the record length is 16…
Using wm flatfile package, Fixed Length flatfile can be created… But not with delimiters…
Case I: Normal Fixed Length Flatfile without delimiters
Create dictionary - Field definition with positions starting from 0
In schema, set the dictionary through Properties window…
Select the Record parser as Delimiter and Record separater as New Line…
This brings an output like this for an input of 3 records…
AAABBB DDD
AAABBB DDD
AAABBB DDD
Case II: Fixed Length flatfile with delimiters
If you wanna output like AAA|BBB | |DDD, the record length is going to change… ie., 16+3 = 19 where | symbols are also considered as some fields… Different approach is required to achieve this…
Create dictionary
RecordName
field1 0-4
field2 4-5 (This is for delimiters. While mapping other variables, hardcode it to |)
field3 5-10
field4 10-11 (delimiter)
field5 11-16
field6 16-17 (delimiter)
field7 17-20
Create schema
Choose Delimiter option
Record Separater as New Line character
In the flatfile tab, set the dictionary through Properties
This brings an output like below
AAA |BBB | |DDD
AAA |BBB | |DDD
AAA |BBB | |DDD
There may be different way also… Others can suggest their views…