views:

827

answers:

3

I have a flat-file schema that has a header and detail records. It looks something like this:

HDR**2401*XX0062484*22750***20081006000000*000*******
LIN**001*788-0538-001*4891-788538010*20000*EA**0000***

I need to append two blank lines at the end of the message. Right now, if I have multiple records I get the following output:

HDR**2401*XX0062484*22750***20081006000000*000*******
LIN**001*788-0538-001*4891-788538010*20000*EA**0000***
HDR**2401*XX0062484*22750***20081006000000*000*******
LIN**001*788-0538-001*4891-788538010*20000*EA**0000***

What I want to see happen is something like this:

HDR**2401*XX0062484*22750***20081006000000*000*******
LIN**001*788-0538-001*4891-788538010*20000*EA**0000***


HDR**2401*XX0062484*22750***20081006000000*000*******
LIN**001*788-0538-001*4891-788538010*20000*EA**0000***

I could build a custom pipeline component to do this, but I'm wondering if there is a simpler way of getting what I need?

Thanks.

A: 

For anybody who cares, I finally caved in and wrote a custom pipeline component to accomplish this.

sbanwart
+1  A: 

You should be able to accomplish what you want by using the Delimiter properties of the flat file schema.

Based on your example file I created a schema with the following record structure:

<Schema>    
  <Root>    
    <HDRGroup>    
      <HDR>    
      <LIN>    

If you click on the root node of your schema you should see a list of properties for this root node. One properties section has the header 'Flat File'. In this flat file section the first three properties you can set are Child Delimiter, Child Delimiter Type and Child Order.

This is where you configure the schema to create the blank lines (in this case CR LF but you can set different things as you need) For your example I set the following:

Child Delimiter: 0x0D 0x0A 0x0D 0x0A    
Child Delimiter Type: Hexadecimal    
Child Order: Infix

0x0D 0x0A is a carriage return line feed, so the above simply creates two blank lines, infixed between each child of the root node.

The <HDRGroup> then functions to make sure that each header and its lines is kept together. For its delimiter settings I set:

Child Delimiter: 0x0D 0x0A    
Child Delimiter Type: Hexadecimal    
Child Order: Postfix

The <HDR> and <LIN> records then contain the actual schema definition for your message lines, delimited with an asterisk.

This schema works for something that looks to me like what you have asked for - this sort of flatfile schema and how it parses a file is highly dependant of the little details, however, such as what type of line breaks there are and if there are line breaks at the end of the file.

The princples of using the delimiters will stand, you will likely find you need to tinker with the settings.

David Hall
A: 

I am wrestling with the same thing and what I have come down to, in my situation is the receive component is debatching records and sending one over @ a time, resulting in my mapper/flatfile schema writing just one record at a time and not outputting CRLF as it appends each record. Can you give me a bit of info. about how you did this in custom pipeline?

bryan meek