| |
| Mapping |
: |
How to find the number of success , rejected and bad records in the same mapping. |
| Explanation |
: |
| In this Mapping we will see how to find the number of success , rejected and bad records in one mapping. |
| |
- Source file is a flat file which is in .csv format . Click here to download the source file.The table appears like as shown below..
| EMPNO |
NAME |
HIREDATE |
SEX |
| 100 |
RAJ |
21-APR |
M |
| 101 |
JOHN |
21-APR-08 |
M |
| 102 |
MAON |
08-APR |
M |
| 103 |
|
22-APR-08 |
M |
| 105 |
SANTA |
22-APR-08 |
F |
| 104 |
SMITHA |
22-APR-08 |
F |
| 106 |
|
|
M |
-
In the above table it shows few values are missing in the table .ANd also the date format of few records are improper.This must be considered as invlaid records and should be loaded into Bad_records table ( target table which is relational).
-
Other than 2 , 3 , 5, 6 records ,remaining all are invalid records because of NULL values or improper DATE format or both .
-
INVALID & VALID RECORDS ::
-
First we seperate this data using Expression transformation.Which is used to flag the row for 1 or 0 .The condition as follows ..
- IIF(NOT IS_DATE(HIREDATE,'DD-MON-YY') OR ISNULL(EMPNO) OR ISNULL(NAME) OR ISNULL(HIREDATE) OR ISNULL(SEX) ,1,0)
-
FLAG =1 is considered as invalid data and FLAG =0 is considered as valid data .This data will be routed into next transformation using router transformation .Here we added two user groups one as FLAG=1 for invalid data and the other as FLAG=0 for valid data.
- FLAG=1 data is forwarded to the expression transformation .Here we take one variable port and trwo ouput ports .One for increament purpose and the other for flag the row ...
- INVALID RECORDS
- INCREAMENT ::
PORT |
EDIT EXPRESSION |
COUNT_INVALID |
V_PORT ( output port ) |
V_PORT |
V_PORT+1 ( variable) |
- INVALID DATE ::
PORT |
EDIT EXPRESSION |
INVALID_DATE |
IIF( IS_DATE(O_HIREDATE,'DD-MON-YY'), O_HIREDATE, 'INVALID DATE') |
- This data will be moved to the BAD_RECORDS table.Look at the below table::
| EMPNO |
NAME |
HIREDATE |
SEX |
COUNT |
| 100 |
RAJ |
INVALID DATE |
M |
1 |
| 102 |
MAON |
INVALID DATE |
M |
2 |
| 103 |
NULL |
22-APR-08 |
M |
3 |
| 106 |
NULL |
NULL |
M |
4 |
|
| |
| |
| Download the mapping and execute it in your lab . |
| |
|
| Download |
: |
|
|
|
|
|