In my last post [link is mentioned below if you haven't gone through it] I had explained how will you generate a TargetFile name dynamically -- means how will you give your target file name from mapping.
http://gyaankatta.blogspot.in/2013/10/generating-target-file-name-dynamically.html
At end of the post, I had mentioned one NOTE particularly specifying that the structure / arrangement will work only for creating a Single File.
Lets assume that you are loading 3 different source files from only one mapping using indirect loading, and you also want to create same number of files as an output with some different name.
How can you achieve that?
1. Indirect File Loading
As mentioned in earlier post [link is below], you need to make arrangements for indirect file loading and also need to add port in source for Currently Processing File Name. By this you can load number of source files using a single mapping and also process current file name.
http://gyaankatta.blogspot.in/2013/10/indirect-file-loading-and-saving.html
2. File Name column at Target
As per your requirement, you need to create the file names dynamically, meaning you need to pass those filename from mapping otherwise if you specify at Session level it will be a static name and you could not create more than one file.
http://gyaankatta.blogspot.in/2013/10/generating-target-file-name-dynamically.html -- As per this post, make sure that your target will have an additional port "FileName"
Now, if you connect your Source and Target as shown in above image, you can assign a file name dynamically; however you can not create more than one file from this.
Why it won't create more than one file?
Your mapping will get executed as part of one transaction and [ I think so] it will assign first file name which you will read from source as a target file.
To create more than one file, you need to let know the session that mapping has to go through more than one transaction. So session will create one target file for each transaction.
*You can see same scenario in help files of informatica
How can you create more than one transactions ?
Using Transactional Control Transformation, you can create more than one transactions. So, as and when your source file name gets change, you need to create a separate transaction [using transactional control transformation] by which Session will create more than one target files.
You need to add transactional control transformation just before the target definition. The logic will be as below
If your filename is same, continue with same transaction, otherwise create a new transaction.
Do we require a Sorter for sorting file names?
No, we do not need it, as by default informatica will read the files sequentially so even the filenames will come sequentially.
How will you understand the file name got changed?
That you need to achieve creating variable port and storing the old value.
As you can see we have defined a variable to store the Old value of input File Name and we will compare old and current file name to identify the change.
Depending upon the value of ChangedFileFlag we will decide whether to create new transaction or continue with existing.
Session Level Setting
This will be similar to your indirect loading settings, you just have to define load type to Indirect and give the source file name as File which contains actual file list which you are going to load.
Target file name you can give any which is ultimately going to get over-ridden by the name which you are passing via mapping.
You have done with mapping and session level configurations, just run the workflow and validate the results.
http://gyaankatta.blogspot.in/2013/10/generating-target-file-name-dynamically.html
At end of the post, I had mentioned one NOTE particularly specifying that the structure / arrangement will work only for creating a Single File.
Lets assume that you are loading 3 different source files from only one mapping using indirect loading, and you also want to create same number of files as an output with some different name.
How can you achieve that?
1. Indirect File Loading
As mentioned in earlier post [link is below], you need to make arrangements for indirect file loading and also need to add port in source for Currently Processing File Name. By this you can load number of source files using a single mapping and also process current file name.
http://gyaankatta.blogspot.in/2013/10/indirect-file-loading-and-saving.html
2. File Name column at Target
As per your requirement, you need to create the file names dynamically, meaning you need to pass those filename from mapping otherwise if you specify at Session level it will be a static name and you could not create more than one file.
http://gyaankatta.blogspot.in/2013/10/generating-target-file-name-dynamically.html -- As per this post, make sure that your target will have an additional port "FileName"
Now, if you connect your Source and Target as shown in above image, you can assign a file name dynamically; however you can not create more than one file from this.
Why it won't create more than one file?
Your mapping will get executed as part of one transaction and [ I think so] it will assign first file name which you will read from source as a target file.
To create more than one file, you need to let know the session that mapping has to go through more than one transaction. So session will create one target file for each transaction.
*You can see same scenario in help files of informatica
How can you create more than one transactions ?
Using Transactional Control Transformation, you can create more than one transactions. So, as and when your source file name gets change, you need to create a separate transaction [using transactional control transformation] by which Session will create more than one target files.
You need to add transactional control transformation just before the target definition. The logic will be as below
If your filename is same, continue with same transaction, otherwise create a new transaction.
Do we require a Sorter for sorting file names?
No, we do not need it, as by default informatica will read the files sequentially so even the filenames will come sequentially.
How will you understand the file name got changed?
That you need to achieve creating variable port and storing the old value.
As you can see we have defined a variable to store the Old value of input File Name and we will compare old and current file name to identify the change.
Depending upon the value of ChangedFileFlag we will decide whether to create new transaction or continue with existing.
Session Level Setting
This will be similar to your indirect loading settings, you just have to define load type to Indirect and give the source file name as File which contains actual file list which you are going to load.
Target file name you can give any which is ultimately going to get over-ridden by the name which you are passing via mapping.
You have done with mapping and session level configurations, just run the workflow and validate the results.
No comments:
Post a Comment