1 file - multiple messages to multiple outputs using header

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
AndyW
Participant
Posts: 3
Joined: Fri Jan 26, 2007 4:01 am
Location: Sheffield

1 file - multiple messages to multiple outputs using header

Post by AndyW »

Hi,
I'm pretty new to datastage and am trying to figure out how to read a File that contains multiple "messages" (made up of a header and a detail section). Everytime the file is sent any number of of messages can be sent and each message can be a different length and structure. Each message however will specifiy the length of it's detail and it's message type within it's Header section. Example the following is the structure of File A that contains 4 messages: -

File A
======
Header: Type 1, 15 (MessageName, length of Detail section)
Detail: MR SMITH, 12345 (Field 1, Field 2)
Header: Type 2, 12 (MessageName, length of Detail section)
Detail: 12, CAT, ABC (Field 1, Field 2, Field 3)
Header: Type 3, 6 (MessageName, length of Detail section)
Detail: 123ABC (Field 1)
Header: Type 1, 15 (MessageName, length of Detail section)
Detail: MR JONES, 67891 (Field 1, Field 2)

Another complication is that each Type represents a fixed mapping that has to be translated into a new structure and then sent to an output.

Type 1 - Needs to be translated using Map A
Type 2 - Needs to be translated using Map B
Type 3 - Needs to be translated using Map C

E.g.
Is it possilbe to read the first header row, determine the Type (Type 1) and size (15) then pass the detail section through the correct map (Map A) and then this new output be sent to an output file designed for the type provided. The process will then recognise the next header and repeat the process until the end of the file. E.g. Message 1 (Type 1) uses Map A then goes to output 1, Message 2 (Type 2) uses Map B then goes to output 2, Message 3 (Type 3) uses Map C then goes to output 3, Message 4 (Type 1) uses Map A then goes to output 1.

Any pointers on how to approach this would be great.

Thanks Andy
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Welcome Andy. :D

You've picked an interesting problem for a newbie to solve. I don't have time to do this answer justice, but check out a few things:

* Define the record to be read as one long varchar, a single string.
* Use the Field function in the first transformer to split the record around the first colon. Do they actually say 'Header:' and 'Detail:' in each row? You could also check for that.
* Multiple output links, one for each type - if there is a known finite number of types
* The Row Splitter stage may help break the detail out of each Detail record, or you could do it 'by hand' using the Field function again.

Food for thought... someone else will be along shortly. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

You can do that in TX :?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Oh, crap... didn't even notice that this was a TX question. Should have tumbled to that when you said 'map'. :evil:

Andy, you need to repost this down in the forum dedicated to TX if that's the case, the experts on that product only seem to hang out there.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Plus I'm curious as to which customer is using TX in Sheffield since I happen to be located in Yorkshire at present 8)
Post Reply