1 file - multiple messages to multiple outputs using header

Formally known as "Mercator Inside Integrator 6.7", DataStage TX enables high-volume, complex transactions without the need for additional coding.

Moderators: chulett, rschirm

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
jvmerc
Participant
Posts: 94
Joined: Tue Dec 02, 2003 12:57 pm

Post 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?
AndyW
Participant
Posts: 3
Joined: Fri Jan 26, 2007 4:01 am
Location: Sheffield

Post 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
janhess
Participant
Posts: 201
Joined: Thu Sep 18, 2003 2:18 am
Location: UK

Post 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.
Last edited by janhess on Tue Jan 30, 2007 3:09 am, edited 1 time in total.
jvmerc
Participant
Posts: 94
Joined: Tue Dec 02, 2003 12:57 pm

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