Pages

May 22, 2012

Merging Two records

Merging Two records


//we will explore how to correct such a situation by merging two records including
//all their related transactions. For the demonstration, we will merge two vendor accounts 5001
//and 5002 into a single one, that is, 5001.

static void VendAccountMerge(Args _args)
{
VendTable vendTable;
VendTable vendTableDelete;
PurchJournalAutoSummary jourSummary;
#define.vend('5001')
#define.vendDelete('5002')
;

     ttsbegin;
delete_from jourSummary
where jourSummary.VendAccount == #vendDelete;
select firstonly forupdate vendTableDelete
where vendTableDelete.AccountNum == #vendDelete;
select firstonly forupdate vendTable
where vendTable.AccountNum == #vend;
vendTableDelete.merge(vendTable);
vendTable.doUpdate();
vendTableDelete.doDelete();
     ttscommit;
}

No comments:

Post a Comment

Thanks