Page 1 of 1

1 file - multiple messages to multiple outputs using header

Posted: Fri Jan 26, 2007 7:47 am
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

Posted: Fri Jan 26, 2007 8:04 am
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:

Posted: Fri Jan 26, 2007 8:05 am
by DSguru2B
You can do that in TX :?

Posted: Fri Jan 26, 2007 8:07 am
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.

Posted: Fri Jan 26, 2007 8:32 am
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)