Page 1 of 1

transformer-2 set of records in o/p link for one i/p record

Posted: Sun Jul 03, 2005 11:28 pm
by Roshni
hi,
i am looking for a solution to pass two set of output records in the transformer to a sequential file for a single incoming record under certain conditions.
i have customerno, accountno and a key coming from the input link. if the key is same for two customerno, i have to log an error which contains the columns: customerno, accountno and key. so, whenever a duplicate record is located using stage variables, i want to write the old customerno and the new customerno with the same key as separate records to the error file along with their curresponding accountno and key.

Re: transformer-2 set of records in o/p link for one i/p rec

Posted: Mon Jul 04, 2005 12:47 am
by Kirtikumar
Roshni wrote:so, whenever a duplicate record is located using stage variables, i want to write the old customerno and the new customerno with the same key as separate records to the error file along with their curresponding accountno and key.
Earlier, I have done the same thing, but in my case I had just sent the second duplicate record to the reject file.

To achieve your requirement, you may have to retain the previous row in stage variables. The logic that I can think of is something like follows:

Define 4 stagevars as 3 for input cols and one as dupl flag.
The derivations will be as follows:
SVarCustNo:

Code: Select all

If Link.Key = SVarKey Then
    SVarCustNo
Else
    Link.CustNo
SVarAccNo:

Code: Select all

If Link.Key = SVarKey Then
    SVarAccNo
Else
    Link.AccNo
SVarDupl

Code: Select all

If Link.Key <> SVarKey Then
    'N'
Else
    If SVarDupl = 'Y' Or SVarDupl = 'A' Then
        'A'
    Else
        'Y'
SVarKey:

Code: Select all

Link.SVarKey
Then there will be 2 error links with 2 different files. On the first link you will output current record by setting column values to current link and its constraint will be:

Code: Select all

SVarDupl = 'Y' Or SVarDupl = 'A' 
On the second link you will output old record by setting column values to stagevariable which are holding last row values and the constraint will be:

Code: Select all

SVarDupl = 'Y'
The SVarDupl derivation also handles a case where more than 2 subsequent rows have same Key value. When more than 2 rows have same key value, the variable will be set to 'A' i.e. already sent old record and only current row will be added to reject file.

Now as we have 2 file, call Afterjob subroutine DSExecute to sort and merge these 2 files on KEY column so that output of this will one concatenated Reject file.

There may be some better alternative way to achieve this, but I would have done this as aforesaid.

Hope this helps.

Posted: Mon Jul 04, 2005 3:26 am
by Sainath.Srinivasan
This is a duplicate post and has been answered in the other one.