UPDATE VS4TAPCreditNoteMB Set TPCMCostAmount=TPCMNetAmount * -1, TPCMCost=TPCMNetAmount/TPCMQuantityCalc*-1 WHERE TPCMCostAmount is null
GO
UPDATE VS4TAPInvoiceMB Set TIPMFlag2=(SELECT TIAPType FROM VS4TAPInvoice WHERE VS4TAPInvoiceMB.TIPMTIAPNo=VS4TAPInvoice.TIAPNo)
GO
UPDATE VS4TAPInvoiceMB Set TIPMCostAmount=(SELECT TPCMCostAmount FROM VS4TAPCreditNoteMB WHERE VS4TAPInvoiceMB.TIPMTIAPNo=VS4TAPCreditNoteMB.TPCMTPCNNo AND VS4TAPInvoiceMB.TIPMLn=VS4TAPCreditNoteMB.TPCMLn) WHERE TIPMFlag2=20
GO
UPDATE VS4TAPInvoiceMB Set TIPMCost=(SELECT TPCMCost FROM VS4TAPCreditNoteMB WHERE VS4TAPInvoiceMB.TIPMTIAPNo=VS4TAPCreditNoteMB.TPCMTPCNNo  AND VS4TAPInvoiceMB.TIPMLn=VS4TAPCreditNoteMB.TPCMLn) WHERE TIPMFlag2=20
GO