one file with multiple layouts

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
Aggie99
Participant
Posts: 54
Joined: Thu Sep 04, 2008 6:54 pm

one file with multiple layouts

Post 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.
ragasambath
Participant
Posts: 12
Joined: Wed Oct 03, 2007 9:11 am
Location: London

Re: one file with multiple layouts

Post 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
Regards

Raga
Aggie99
Participant
Posts: 54
Joined: Thu Sep 04, 2008 6:54 pm

Post by Aggie99 »

thanks raga.

can you elaborate on option3, I have not used it before. I am keen on this option.
abhijain
Participant
Posts: 88
Joined: Wed Jun 13, 2007 1:10 pm
Location: India

Post 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.
Rgrds,
Abhi
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post 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.
dsedi
Participant
Posts: 220
Joined: Wed Jun 02, 2004 12:38 am

Post by dsedi »

Please explore the options of head stage. we guess with the correct partition/skip properties setup this can be done.
Accept that some days you're the pigeon and some days you're the statue.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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?
-craig

"You can never have too many knives" -- Logan Nine Fingers
siauchun84
Participant
Posts: 63
Joined: Mon Oct 20, 2008 12:01 am
Location: Malaysia

Post 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.
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post 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
nagarjuna
Premium Member
Premium Member
Posts: 533
Joined: Fri Jun 27, 2008 9:11 pm
Location: Chicago

Post 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
Nag
Post Reply