Tuesday, April 8, 2014

How to seperate header and Footer from Flat File using Informatica

Scenario:
Source File is flat file which contains Header, Detail and Footer. Scenario is to Load the Header records into Header table ,Detail records into Detail table and Footer records into Footer table.

Source File (Source.txt)
H Company Name : Header
#####################

   Acc_num      Amount
D 123                 200
D 456                 300
D 345                 200

#####################
F No. of records : 3


Solution:

Follow the steps:

1. Import the file.

2. Create a mapping with source as file and Source Qualifier for the file.

3. Connect the Source Qualifier to an Expression Transformation.

4. In Expression Transformation take 1 port as Input port which is File, type of port will be string and length is max length of one row in Source File.

5. In Expression Transformation create three variable ports and three out ports
    v_Header=IIF(SUBSTR(File,1,1)='H',1,0)
    o_Header=v_Header
    v_Footer=IIF(SUBSTR(File,1,1)='F',1,0)
    o_Footer=v_Footer
    v_Detail=IIF(SUBSTR(File,1,1)='D',1,0)
    o_Detail=v_Detail

6. Connect Expression Transformation to a Router Transformation. Router Transformation will have  three groups.
    a. IIF(o_Header=1) -- Pass this group data to target Header Table
    b. IIF(o_Detail=1)  -- Pass this group data to target Detail Table
    c. IIF(o_Footer=1) -- pass this group data to target Footer Table
   
 

No comments:

Post a Comment