ProjTransPosting projTransPostingOrig,projTransPostingInsert;
ttsbegin;
while select forupdate projTransPostingOrig
where projTransPostingOrig.Voucher == _voucherNo &&
projTransPostingOrig.PaymentStatus == ProjPaymentStatus::ExpectedPayment
{
// Check to see if the partial payment needs to be done
if (_partialPayment)
{
// Copy the row to be inserted
projTransPostingInsert.data(projTransPostingOrig);
// Copy the original amount and qty
originalQty = projTransPostingOrig.Qty;
originalAmount = projTransPostingOrig.AmountMst;
// get percentage of partial payment
partialAmount = Currency::amount(originalAmount * _percentagePayment);
partialQty = decRound(originalQty * _percentagePayment, 2);
// insert new record
projTransPostingInsert.AmountMst = originalAmount - partialAmount;
projTransPostingInsert.Qty = originalQty - partialQty;
projTransPostingInsert.PaymentStatus = ProjPaymentStatus::ExpectedPayment;
projTransPostingInsert.insert();
// We need to edit the existing record to reflect the partial payment
projTransPostingOrig.AmountMst = partialAmount;
projTransPostingOrig.Qty = partialQty;
}
projTransPostingOrig.PaymentStatus = _paymentStatus;
projTransPostingOrig.PaymentDate = _paymentDate;
projTransPostingOrig.update();
}
ttscommit;
it works with small number of records but it doesn't work for case i have 300 Record it continue to loop for more than 300 and i don't know why exactly this case happened and table have only 300 record