Antony Kumar


Currently looping through the set of flat files like CHK0604, CHK0611, CHK0618, and CHK0625 from the source folder C:\SOURCE

OBJECTIVE within the flat file if any records/rows cause error i have to move the bad data into separate folder C:\ERROR

STEPS TAKEN

1) In FOREACH LOOP component i specified the variable User:: sourceFilePath for my source file CHK0604 etc. location C:\SOURCE. The loop walkthrough each file in C:\SOURCE and if no error then moves the flat file into another folder C:\ARCHIVED. This task is perfectly working.

2) Within the dataflow I am diverting the the bad rows from "conditional component" into "Flat File Destination" Component.

3) "Flat File Destination" Connection manager i set the expressions as @[User:: sourceFilePath] +"_Error.TXT".

ISSUE

Because of point (3) the error file is created in the SOURCE flat file location C:\SOURCE.

QUESTION

1) My error file name should be CHK0604_Error, CHK0611_Error, CHK0618_Error, CHK0625_Error created in another folder C:\ERROR.

2) How to move the bad data into another directory while looping through a set of FLAT FILES

3) If i have to create another variable like @[User:: ErrorFilePath] where to create How to use the source file title as the title of error file.

Thanks for the help





Re: How to move the bad data into another directory while looping through a set of FLAT FILES ?

jwelch


As a really simple (and not very robust) workaround you could use the following expression in your flat file destination connection manager:

REPLACE(@[User:Tongue TiedourceFilePath], "SOURCE", "ERROR") + "_Error.TXT"

A more robust solution would be to parse the sourceFilePath variable to get the filename, and use a seperate variable to set the error path.







Re: How to move the bad data into another directory while looping through a set of FLAT FILES ?

Antony Kumar

Will it(REPLACE fun) move the bad data into separate folder C:\ERROR

How to get the filename from the SourceFilePath Variable

Where to set the seperate variable to set the error path

Thank you Jwelch







Re: How to move the bad data into another directory while looping through a set of FLAT FILES ?

jwelch

You'd put the REPLACE expression on the connection string for the error flat file connection manager. Then your error files will end up in the ERROR folder.

To parse the filename, I'd use a script component and the System.IO.Path.GetFileName method.

Where you set the error path variable is really your call, but I would create the variable at the package level.