AX tidak bisa melakukan pemotongan karakter pada query nya. Misal:
select * from table
where substr(table.name,3,5) = '12345'
oleh karena itu harus dilakukan cara sbb:
LedgerTrans lt;
LedgerJournalTrans ljt;
Voucher vch;
str 60 text;
str 250 text2;
;
vch ='GBV113-000903';
select firstonly *
from ljt
where ljt.Voucher ==vch;
while select *
from lt
where lt.Voucher ==vch
{
if(lt.AmountMST >0)
{
select firstonly *
from ljt
where ljt.Voucher == vch
&& ljt.AmountCurDebit == lt.AmountMST;
}
else
{
select firstonly *
from ljt
where ljt.Voucher == vch
&& ljt.AmountCurCredit == abs(lt.AmountMST);
}
text = ljt.txt;
text2 = text;
if( lt.Txt==text)
{
text2= ljt.Txt;
}
info(strfmt('%1 %2',lt.AmountMST,text2));
}
Sunday, May 19, 2013
Validasi create, edit, dan delete data berdasar kondisi field
Timpa method asli, lakukan modifikasi pada Datasource
public int active()
{
int ret;
ret = super();
if(Table.Posted==NoYes::Yes)
{
Table_ds.allowEdit(false);
Table_ds.allowDelete(false);
Table_ds.allowCreate(false);
}
else
{
Table_ds.allowEdit(true);
Table_ds.allowDelete(false);
Table_ds.allowCreate(false);
}
return ret;
}
public int active()
{
int ret;
ret = super();
if(Table.Posted==NoYes::Yes)
{
Table_ds.allowEdit(false);
Table_ds.allowDelete(false);
Table_ds.allowCreate(false);
}
else
{
Table_ds.allowEdit(true);
Table_ds.allowDelete(false);
Table_ds.allowCreate(false);
}
return ret;
}
Menyalin data dalam table yg sama (copy record)
Table tbl0,tlb1;
Numberx id;
;
/** #1.Filter data yg akan di-copy **/
select * from tbl0
where tbl0.id == '12345';
tbl1 = tbl0;
ttsbegin;
tbl1.data(tbl0);
/** #2.Lakukan update field yg diperlukan **/
tbl1.duplicated = Noyes::Yes;
tbl1.CreatedDateTimex = DateTimeUtil::getSystemDateTime();
if (!tbl1.validateWrite())
{
throw Exception::Error;
}
/** #3. Simpan **/
tbl1.insert();
ttscommit;
Numberx id;
;
/** #1.Filter data yg akan di-copy **/
select * from tbl0
where tbl0.id == '12345';
tbl1 = tbl0;
ttsbegin;
tbl1.data(tbl0);
/** #2.Lakukan update field yg diperlukan **/
tbl1.duplicated = Noyes::Yes;
tbl1.CreatedDateTimex = DateTimeUtil::getSystemDateTime();
if (!tbl1.validateWrite())
{
throw Exception::Error;
}
/** #3. Simpan **/
tbl1.insert();
ttscommit;
Subscribe to:
Posts (Atom)