Saturday 26 October 2013

Indirect File Loading and Saving Current Processing FileName..

This question I had asked at the time of interview to at least dozens of people; most of them could answer first part of it i.e. Indirect File Load; however, second part i.e. Saving Current FileName people were unaware of.

Part -1 Indirect File Load --

When you need to use Indirect File Load ?
Lets assume you have file coming in from different countries, each file has same structure, and you want to process all those files using a single mapping. You can achieve this by Indirect File Load.

Import Source -- Lets assume you have 3 files India.csv. UK.csv and USA.csv coming from different countries having same file structure. You can import any of the file to import as a Source.

Import Target -- Once you import your Source, just drag it to Target Designer so same will become as your target.

Mapping -- Your mapping structure will be simple i.e Source -- Source Qualifier -- Target


As you can see, above is the mapping structure which has only Source -- Source Qualifier -- Target.

Next remaining task is to Create a Workflow --
Once you create a workflow which is mapped with above mapping, you need to change some settings at Session Task which you have created.

Specifying Indirect Load and Source File Name --
Now, first thing which we need to change is the Load Type at session level; by default it will be Direct, which you need to change to InDirect.

As shown in above image, we have changed Source FileType to Indirect
Also, filename we have specified is FileList.csv -- this is not the actual file which you are intended to load, but it contains names of all files which you have planned to load.

In this case, structure of FileList.csv will be as below


As shown in this image, your filename [in case of indirect load] will contain list of file names which you are planning to load

Also, make sure that FileList and Other Files should be in same directory which you have specified in "Source File Directory" option.

If source other files are at different physical location, then you need to specify its full path in your FileList.csv

Target Level Session Task Settings --
As in the image above, you just have to specify Target File Directory and Target File Name.

Once you do that, you are done with the development and your workflow is ready for execution.

Part -2 Loading Current Processing File Name --
Lets assume that your client asked you to also load the corresponding file name along with the data at your target, so that customer can identify particular data belongs to which region.

Change at Source -- As you need to populate FileName along with the data, you need to retrieve the currently processing file name along with the Data from Source.

How will you get Current Processing FileName ?
As you can see in image, Informatica Source Analyzer gives you an option to populate Currently Processing File Name along with other data. When you click on the Check Box above at Source, automatically one extra port gets added at end, as below



As you can see, a new port gets added automatically when you check the above specified option.

Just similarly add one more port to your target to same the currently processing file name.

Note -- A new port which gets added at Source, will have whole Source File Path and not only the file name.

Connect Currently Processed File name from source till target.

Save and Validate your mapping and refresh the workflow and execute it.

Now the same output file which you had specified above, will get updated [records won't get added / updated if the file is already exists.] with new records



No comments:

Post a Comment