Hi,
In CustTrans table create the following two methods:
/// This is the inner query which you have written to fetch the recId of CustTrans table
static RecId findCTRecId(RefRecId _refRecId, AccountNum _accountNum)
{
CustTrans custTrans;
;
select RecId from custTrans
where custTrans.RecId == _refRecId &&
custTrans.AccountNum != _accountNum;
return custTrans.RecId;
}
////Also, write another method to get the accountnum from CustTrans table to update the value in CustSettlement table
static AccountNum findCTAccountNum(RefRecId _refRecId, AccountNum _accountNum)
{
CustTrans custTrans;
;
select AccountNum from custTrans
where custTrans.RecId == _refRecId &&
custTrans.AccountNum == _accountNum;
return custTrans.AccountNum;
}
Once you have created these above methods then replace your SQL query to the following X++ statement
CustSettlement custSettlement;
;
if(curext() == "DAT")
{
ttsbegin;
select forUpdate custSettlement
where custSettlement.AccountNum == "1"; &&
custSettlement.TransRecId == CustTrans::findCTRecId(custSettlement.TransRecId, custSettlement.AccountNum);
custSettlement.AccountNum = CustTrans::findCTAccountNum(custSettlement.TransRecId, custSettlement.AccountNum);
custSettlement.update();
ttscommit;
}
Hope it would help you.
Good luck!
Regards,
Kris
----- Original Message ----
From: padmaja_wipro < padmaja_wipro%40yahoo.com">padmaja_wipro
yahoo.com>
To: development-axapta%40yahoogroups.com">development-axapta
yahoogroups.com
Sent: Friday, 14 March, 2008 12:46:46 AM
Subject: [development-axapta] what is the equivalent X++ statement for this SQL query
update custsettlement
set accountnum =
(select accountnum from custtrans
where dataareaid=' DAT'
and recid=custsettlemen t.transrecid
and ltrim(rtrim( accountnum) )=ltrim(rtrim
(custsettlement. accountnum) ))
where dataareaid=' DAT'
and ltrim(rtrim( accountnum) )='1'
and transrecid in
(select recid from custtrans
where dataareaid=' dat'
and recid=custsettlemen t.transrecid
and ltrim(rtrim( accountnum) )<>ltrim( rtrim
(custsettlement. accountnum) ))
Thanks in advance.
Padmaja
Get the freedom to save as many mails as you wish. To know how, go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
[Non-text portions of this message have been removed]
.