CustTrans invCustTrans;
CustTrans payCustTrans;
CustTable custTable;
AccountNum invoiceaccount;
/* 0a. Nomor invoice dan nomor payment harus sudah diketahui
dan di-input pada saat pembuatan jurnalnya
*/
/* 1. Pilih dulu invoice nya, kalo perlu gunakan where AccountNum*/
invoiceaccount = [Kode Customer];
custTable = CustTable::find(invoiceaccount);
Select firstonly invCustTrans
order by TransDate asc
where invCustTrans.Invoice == [InvoiceNumber]
&& invCustTrans.TransType == LedgerTransType::Sales;
if(invCustTrans) /* 2.Cek bila ada data invoice*/
{
//info('invoice '+invCustTrans.Invoice);
/* 3.Lakukan marking Invoicenya*/
custVendTransData = CustVendTransData::construct(invCustTrans);
custVendTransData.markForSettlement(CustTable);
/* 4.Pilih payment nya*/
ttsbegin;
while select payCustTrans
order by TransDate asc
where payCustTrans.DocumentNum == [PaymentNumber]
&& payCustTrans.TransType == 0
&& payCustTrans.AccountNum == invCustTrans.AccountNum
{
//info('Payment no '+[PaymentNumber]);
/* 5.Lakukan marking paymentnya*/
custVendTransData = CustVendTransData::construct(payCustTrans);
custVendTransData.markForSettlement(CustTable);
PaymentDate = [PaymentDate];
}
ttscommit;
/* 6. Proses Settlement nya */
/* SettleDatePrinc::SelectDate, tgl settle diinput (ditentukan) manual */
CustTrans::settleTransact(custTable, null, true,SettleDatePrinc::SelectDate, PaymentDate);
}
Thursday, January 2, 2014
Sunday, May 19, 2013
Ambil teks dari LedgerJournalTrans
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));
}
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));
}
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;
Thursday, December 27, 2012
Kirim email dari AX 2009
Catatan: mailTo hanya bisa diisi 1 email, bila lebih, maka hanya email yg pertama saja yg diproses.
void Send_Emailx(str subjectx,str bodyx,str sendtomailx,str sendtonamex)
{
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.SmtpClient myMail;
System.Net.Mail.MailAddressCollection mailcoll;
System.Net.Mail.MailAddress mailFrom;
System.Net.Mail.MailAddress mailTo,mailTo2;
System.Net.Mail.MailAddress mailCC;
str receiverMailAddress;
str mailBody;
str smtpServer;
str mailSubject;
str CcMailAddress;
int SMTPPort;
#File
str mail,companynamex;
userinfo userInfo;
str pwd;
SysEmailParameters parameters = SysEmailParameters::find();
;
new InteropPermission(InteropKind::ClrInterop).assert();
mailSubject = subjectx;
companynamex = companyinfo::find().Name;
mailFrom = new System.Net.Mail.MailAddress(parameters.SMTPUserName , "AX Server "+companynamex);
mailTo = new System.Net.Mail.MailAddress(sendtomailx,sendtonamex);
mailCC = new System.Net.Mail.MailAddress('mail@gmail.com','mail');
mailcoll = new System.Net.Mail.MailAddressCollection();
mailBody = bodyx;
try
{
smtpServer = SysEmaiLParameters::find(false).SMTPRelayServerName;// using the SMTP server ip mailMessage = new System.Net.Mail.MailMessage(mailFrom,mailTo);
mailmessage.set_Subject(mailSubject);
mailmessage.set_Body(mailBody);
SMTPPort = SysEmaiLParameters::find(false).SMTPPortNumber;
myMail = new System.Net.Mail.SmtpClient(smtpServer, SMTPPort);
//myMail.set_EnableSsl(true);
// Untuk SSL enabled seperti: gmail, smtp.gmail.com, port 465 or 587
myMail.set_EnableSsl(false);
pwd = SysEmaiLParameters::password();
mymail.set_Credentials(New System.Net.NetworkCredential(parameters.SMTPUserName, pwd));
mymail.Send(mailmessage);
}
catch(Exception::CLRError)
{
throw Exception::CLRError;
}
mailMessage.Dispose();
CodeAccessPermission::revertAssert();
}
void Send_Emailx(str subjectx,str bodyx,str sendtomailx,str sendtonamex)
{
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.SmtpClient myMail;
System.Net.Mail.MailAddressCollection mailcoll;
System.Net.Mail.MailAddress mailFrom;
System.Net.Mail.MailAddress mailTo,mailTo2;
System.Net.Mail.MailAddress mailCC;
str receiverMailAddress;
str mailBody;
str smtpServer;
str mailSubject;
str CcMailAddress;
int SMTPPort;
#File
str mail,companynamex;
userinfo userInfo;
str pwd;
SysEmailParameters parameters = SysEmailParameters::find();
;
new InteropPermission(InteropKind::ClrInterop).assert();
mailSubject = subjectx;
companynamex = companyinfo::find().Name;
mailFrom = new System.Net.Mail.MailAddress(parameters.SMTPUserName , "AX Server "+companynamex);
mailTo = new System.Net.Mail.MailAddress(sendtomailx,sendtonamex);
mailCC = new System.Net.Mail.MailAddress('mail@gmail.com','mail');
mailcoll = new System.Net.Mail.MailAddressCollection();
mailBody = bodyx;
try
{
smtpServer = SysEmaiLParameters::find(false).SMTPRelayServerName;// using the SMTP server ip mailMessage = new System.Net.Mail.MailMessage(mailFrom,mailTo);
mailmessage.set_Subject(mailSubject);
mailmessage.set_Body(mailBody);
SMTPPort = SysEmaiLParameters::find(false).SMTPPortNumber;
myMail = new System.Net.Mail.SmtpClient(smtpServer, SMTPPort);
//myMail.set_EnableSsl(true);
// Untuk SSL enabled seperti: gmail, smtp.gmail.com, port 465 or 587
myMail.set_EnableSsl(false);
pwd = SysEmaiLParameters::password();
mymail.set_Credentials(New System.Net.NetworkCredential(parameters.SMTPUserName, pwd));
mymail.Send(mailmessage);
}
catch(Exception::CLRError)
{
throw Exception::CLRError;
}
mailMessage.Dispose();
CodeAccessPermission::revertAssert();
}
Lihat daftar file pada folder
static void Test_ListDirFiles(Args _args)
{
FilePath filePath = 'X:\\DATA\\MyFolder';
FileNameFilter fileFilter = ["*.*", "All files"];
FileName fileName;
int fileHandle;
;
[fileHandle, fileName] = WinAPI::findFirstFile(strFmt("%1\\%2", filePath, conPeek(fileFilter, 1)));
while(fileName)
{
info(strFmt("%1%2", filePath, fileName));
fileName = winAPI::findNextFile(fileHandle);
}
}
{
FilePath filePath = 'X:\\DATA\\MyFolder';
FileNameFilter fileFilter = ["*.*", "All files"];
FileName fileName;
int fileHandle;
;
[fileHandle, fileName] = WinAPI::findFirstFile(strFmt("%1\\%2", filePath, conPeek(fileFilter, 1)));
while(fileName)
{
info(strFmt("%1%2", filePath, fileName));
fileName = winAPI::findNextFile(fileHandle);
}
}
Memindahkan file ke folder lain
static void Test_Move_One_File(Args _args)
{
System.Exception ex;
Set permSet = new Set(Types::Class);
str errorMsg;
FileName _srcFile,_destFile;
;
_srcFile = "c:\\DATA\\Asal\\copy.txt";
_destFile = "c:\\DATA\\Tujuan\\copy.txt";
try
{
permSet.add(new FileIOPermission(_srcFile, 'rw'));
permSet.add(new InteropPermission(InteropKind::ClrInterop));
permSet.add(new FileIOPermission(_destFile, 'rw'));
CodeAccessPermission::assertMultiple(permSet);
if(!System.IO.File::Exists(_srcFile))
{
Info("Source file not exist !! Proces terminated.");
Break;
}
else
{
Info("Source file exist !! File will be moved.");
if(System.IO.File::Exists(_destFile))
{
System.IO.File::Delete(_destFile);
}
}
System.IO.File::Move(strfmt(@"%1",_srcFile), strfmt(@"%1",_destFile));
CodeAccessPermission::revertAssert();
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
//return true;
}
{
System.Exception ex;
Set permSet = new Set(Types::Class);
str errorMsg;
FileName _srcFile,_destFile;
;
_srcFile = "c:\\DATA\\Asal\\copy.txt";
_destFile = "c:\\DATA\\Tujuan\\copy.txt";
try
{
permSet.add(new FileIOPermission(_srcFile, 'rw'));
permSet.add(new InteropPermission(InteropKind::ClrInterop));
permSet.add(new FileIOPermission(_destFile, 'rw'));
CodeAccessPermission::assertMultiple(permSet);
if(!System.IO.File::Exists(_srcFile))
{
Info("Source file not exist !! Proces terminated.");
Break;
}
else
{
Info("Source file exist !! File will be moved.");
if(System.IO.File::Exists(_destFile))
{
System.IO.File::Delete(_destFile);
}
}
System.IO.File::Move(strfmt(@"%1",_srcFile), strfmt(@"%1",_destFile));
CodeAccessPermission::revertAssert();
}
catch (Exception::CLRError)
{
ex = ClrInterop::getLastException();
if (ex != null)
{
ex = ex.get_InnerException();
if (ex != null)
{
error(ex.ToString());
}
}
}
//return true;
}
Subscribe to:
Posts (Atom)