Search This Blog

Monday, February 15, 2010

To Create file dynamically based on the ID

When you want to create a file dynamically with file name and the data with same details must go the same file we can do this by simple methods.

For Ex:

Claim_Id, Claimant_Name, Claim_Unit

15243,Rags,12354

15243,Rags,12356

15243,Rags,12375

15245,Mars,12355

15246,Pras,12388

In order to generate a file based on the Claim_id we have to do the following steps.

In target create the Filename port.

If the source is the relational source the flow is

SQ—->EXP—->TC——>TGT

In the SQ Query give the order by clause

If the source is the flat file follow

SQ—->SRT—->EXP—->TC—->TGT

Steps followed in the Expression transformation are

Create 2 variable and output ports in the expression transformation.

file_status_v (VAR)—-> IIF ((expgrp_prev = 0) OR (Claim_Id= expgrp_prev),’N',’Y' )

expgrp_prev (VAR)—-> Claim_Id

file_status (Out) —–> file_status_v

filename_o (Out) —–> CONCAT(CONCAT(‘Timmy’,Claim_Id),’.txt’)

After the expression transformation use this below condition in Transaction Control Transformation

IIF
(
file_status = ‘N’,TC_CONTINUE_TRANSACTION,TC_COMMIT_BEFORE
)

Then connect the output ports to the target and the filename_o to the filename port in the target.

The file will be as follows.

Timmy15243.txt

Timmy15245.txt

Timmy15246.txt

No comments:

Post a Comment