Search code examples
shellunixinformaticainformatica-powercenter

Informatica: Process the files only if all records have value Accepted = Y else do not process the whole file


I have multiple files with same layout as source. There is a field called "Accepted". Which can have values Y or N. I want to process only those files that are having values = Y for all the records.

eg):-

File 1
ID   Accepted
1     Y
2     N

File 2
ID   Accepted
1     Y
2     Y

In above case, I should process only File 1. I'm using Informatica PowerCenter for processing the files. There can be n number of files which are read as "Indirect File". Indirect file is created using pre-session korn shell script.

I prefer handling it withing Informatica Mapping, but any solutions using shell script also welcomed. The files are delimited '|' and have many fields not just "ID" and "Accepted"


Solution

  • You can handle this using awk statement when creating indirect file:

    Assume all your input files starts with name "inputfile*"

    flag variable will fetch 2nd field of the file with delimiter as '|'

    A filename is added to indirect file only if there is no "N" in flag variable

    filename=inputfile*
    for f in $filename
    do
    flag=`awk -F "|" '{print $2}' $f`
    if [[ $flag =~ .*N.* ]]
    then
    echo 'Skipping file as one of the record has value =N as accepted'
    else
    echo pwd/$f >>indirectfile
    fi
    done