Académique Documents
Professionnel Documents
Culture Documents
Applies to:
Informatica PowerCenter 8.6.0
Summary
The intention of this paper is to give an idea about validation of a flat file source using information in file
trailor. File will contain total record count in trailor and same will be verified with actual record count received
in file before loading to target. If file is found to be valid, loading will be done else a record will be inserted in
status table indicating that file to be processes is invalid.
Author Bio
Author(s): Avneesh Kumar Rathor
Company: Steria India Ltd.
Created on: Jul 02, 2009
Table of Contents
Table of Contents ............................................................................................................................................... 2
1 Objective ...................................................................................................................................................... 3
2 Source definition .......................................................................................................................................... 3
3 Target definition ........................................................................................................................................... 3
3.1 Target T_FILE_PROCESS_STATUS .................................................................................................................... 3
3.2 Target EMPLOYEE ................................................................................................................................................ 4
4 Mappings ...................................................................................................................................................... 4
4.1 Mapping to validate the source file: m_ValidateSourceFile .................................................................................... 4
4.1.1 Transformations used ......................................................................................................................................... 4
4.2 Mapping to load source file: m_LoadFile................................................................................................................ 7
4.2.1 Transformations used ......................................................................................................................................... 8
5 Sessions ....................................................................................................................................................... 8
6 Workflow ...................................................................................................................................................... 8
1 Objective
The intention of this paper is to give an idea about validation of a flat file source using information in file
trailor. File will contain total record count in trailor and same will be verified with actual record count received
in file before loading to target. If file is found to be valid, loading will be done else a record will be inserted in
status table indicating that file to be processes is invalid.
2 Source definition
Sample flat file source is a comma separated values file having employee records. In addition file is having a
header (starting with H) and a trailor (starting with T). Header record contains file sequence number and
trailor record contains total number of records in file (including header and trailor record).
In sample file total records in file are 16 (including header and trailor). File trailor is “T16”.
Data records are having columns empno, ename, job, mgr, hiredate, sal, comm, and deptno.
3 Target definition
This table will be used to load file information when the file is not valid. In case of a valid file nothing will be
loaded in this table. Example data in this table for invalid file will be as shown below.
4 Mappings
Variable to extract header sequence number is v_HeaderSeqNo, variable to extract trailor record count is
v_TrailorRecCnt and variable to count total number of records in file is v_FileRecCnt.
v_FileRecCnt v_FileRecCnt + 1
AGG_HEADER_TRAILOR_ROWCOUNT
Aggregator is used to make a single row for header sequence number, trailor record count and file record
count.
Output port o_IsFileValid uses below expression to check if trailor record count matches with file record
count. If there is a mismatch then o_IsFileValid flag is set to ‘N’.
FIL_INVALID_FILE
This filter will pass the row only when o_IsValidFile flag is ‘N’ i.e. trailor record count does not match with file
record count.
Filter condition is o_IsFileValid = 'N'.
5 Sessions
Session tasks will be created corresponding to each mapping. Session s_ValidateSourceFile is for mapping
m_ValidateSourceFile.
Session s_LoadFile is for mapping m_LoadFile. As date is source file is in DD-MON-YY format, DateTime
Format String is changed from default to DD-MON-YY. All other settings are default.
6 Workflow
Simple workflow as shown below is created using a start task and two session tasks.
IIF ($s_ValidateSourceFile.TgtSuccessRows = 0,
$s_ValidateSourceFile.Status = succeeded,
$s_ValidateSourceFile.Status = failed)
With this condition is place, session s_LoadFile will execute only when no row is being inserted to target by
session s_ValidateSourceFile. As per the mapping logic, m_ValidateSourceFile will insert the row in target
only when file is failed for validation. So no row inserted in target means file is valid and should be loaded to
EMPLOYEE table using m_LoadFile mapping.
Using sample flat file to execute this workflow will insert no row in T_FILE_PROCESS_STATUS. 14 rows will
be inserted to EMPLOYEE table.