Page 1 of 1

1 file - multiple messages to multiple outputs using header

Posted: Fri Jan 26, 2007 10:00 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 9:29 pm
by jvmerc
Yes, lots of ways to skin this one? Multiple maps, one map multiple outputs....

When you say maps, do you mean run maps or functional maps?

You need to define your type tree(s) appropriately. Think in the terms of loops and initiators.



Just curious, Is the length field/element important?

Posted: Mon Jan 29, 2007 2:15 am
by AndyW
Hi jvmerc,

By Map I mean that the Input coming in on the file is going to be moved/translated at the individual field level into a new output layout that is going to be in a copybook format (using Map Designer). Not sure if this is a run map or a functional one though, sorry.

I wasn't sure if the length field in the header would be required in order to determine where one detail section ended and the next started? If there is another way of determining each header section then no the length field/element is not important.

We will have layouts for all of the different Input messages as well as the corresponding layouts for there outputs (using both Map designer with rules and Tree Types).

I suppose the main points are going to be 1) How do I read certain positions within the header to determine the type and then call one map design 2) then go back and identify the next header to do the same.

Thanks Andy

Posted: Mon Jan 29, 2007 4:11 am
by janhess
Define the file as

Code: Select all

File
  Group(s)
    GroupType1[0:s]
      Header
      Data
    GroupType2[0:s]
      Header
      Data
    GroupType3[0:s]
      Header
      Data
The header Record is made up of 2 items MessageName and length of Detail section. The items have size min 1 max unspecified (unless you know what this is). The record conponent-syntax is delimited with delimiter of ','. The record terminator is <NL>

You will need to set an identifier on the header record type so that you know the associated data record.

The Data record is defined in a similar way.

The Group will need to be unordered.

You can than map tha data as required.

Posted: Mon Jan 29, 2007 8:25 am
by jvmerc
should also be able to import your copybooks which will define your outputs. Historically I've still had to go in and assing terminators etc but if you define your input as descrived by janhess and use you cbks for output you should have this done in no time.

If create one output card for each output file you need and map the data accordingly.

Rules would read something like ...

output card1:
if (present(Header: Type 1), f_map_type_1_detail(input)

output card2:
if (present(Header: Type 2), f_map_type_2_detail(input)

output card3:
..
.
.


f_map_type_1_detail = a funtional map.
input = whatever data to you'll need to map. could be one or more items.