Below example shows how to group output records in multiple files based on a value from the source data.


We have a table with customers and we want to generate a csv file with customers per company:


 

 

First we need to create target file metadata with the output structure (if you have an example of the output file you can use a reverse as for any other delimited file).

However to be able to generate multiple files in one mapping we will have to use a special template("Integration Hierarchical File") and therefore transform our standard metadata into hierarchical file.


Here's how to proceed:

1. Opent the file metadata. Right click on your file New>Record. Make sure to give a name to the record.

2. Move all the fields under the newly created record

3. Drag the file in your mapping and map the fields that you need:

4. Then map the column that you want to use to group the records by on the root field. 

In our example it will be CUS_COMPANY (to generate one file per company):

5. Add a tag on this field (in “Properties” Tab):

6. On the “Record” field map a value that allows to identify the record (for example cus_id). 

It will allow to generate a record per customer in the file:

 

7. Change the template to Integration Hierarchical File:

 

8. And then use the tag in the OUT_MASK_OPTION with [] around the name of the tag:

 

9. When executed the mapping will generate as many files as you have different values in the tagged field (so in our example one file per company):