Page 1 of 1

one file with multiple layouts

Posted: Fri Feb 26, 2010 5:01 am
by Aggie99
I have one text file with 3 different layouts.

content of the file:
the first 5 lines contain header information (layout 1)
line 6 to 20 contains detail record information (layout 2)
line 21 to the end contain trailer information. (layout 3)

how can I read all three formats from the same sequential file?
I want to
read layout 1 and output to dataset 1,
read layout 2 and output to dataset 2,
read layout 3 and output to dataset3.

Can I do that in one job, and avoid all the warnings.

thanks in advance.

Re: one file with multiple layouts

Posted: Fri Feb 26, 2010 5:20 am
by ragasambath
Aggie99 wrote:I have one text file with 3 different layouts.

content of the file:
the first 5 lines contain header information (layout 1)
line 6 to 20 contains detail record information (layout 2)
line 21 to the end contain trailer information. (layout 3)

how can I read all three formats from the same sequential file?
I want to
read layout 1 and output to dataset 1,
read layout 2 and output to dataset 2,
read layout 3 and output to dataset3.

Can I do that in one job, and avoid all the warnings.

thanks in advance.
There are three different ways we approach

1. Using Unix Command split the file into three different parts and load it using separate file stage
2. Load all the records as single row . In the next stage , based on the row count , split the row and assigned to the corresponding column

3. Using complex flat file stage

Posted: Fri Feb 26, 2010 6:17 am
by Aggie99
thanks raga.

can you elaborate on option3, I have not used it before. I am keen on this option.

Posted: Fri Feb 26, 2010 6:36 am
by abhijain
CFF (complex flat file) is a kind of file available under datastage palettel/Files category.
But, I am not sure whether it will fulfill your requirement or not. I never used it.

Posted: Fri Feb 26, 2010 6:46 am
by ArndW
The CFF (Complex Flat File) stage uses data contents to determine record type, i.e. if the first byte contains one value it is record type 1, on another value it is record type 2, etc.
In this case it is line dependent, so I would read the data as one VarChar() column then use @INROWNUM in a transform stage to differentiate the 3 types of content.

Posted: Fri Feb 26, 2010 10:45 am
by dsedi
Please explore the options of head stage. we guess with the correct partition/skip properties setup this can be done.

Posted: Fri Feb 26, 2010 11:08 am
by chulett
Just want to clarify - there's no "record type" field or any way to know which rows are which type, it is strictly driven by record number?

Posted: Tue Mar 02, 2010 2:36 am
by siauchun84
For me, I will use a sequential stage to read the file in varchar (set a max value, let say 1000), then use a transformer to split it into 3 different layout stated, each output use a column import to generate the needed column information and then load to the dataset.

Posted: Sun Mar 07, 2010 11:42 am
by Sreenivasulu
What 'siachun84' says looks to be a simpler approach.
First take all the columns in a single column and then split according to logic

Regards
Sreeni

Posted: Sun Mar 07, 2010 3:53 pm
by nagarjuna
What is the source of the file ? Is it coming from mainframe ? You can use CFF or use transformer and split the file