AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 27.07.2007, 17:30   #1  
Blog bot is offline
Blog bot
Участник
 
25,640 / 848 (80) +++++++
Регистрация: 28.10.2006
Arijit Basu: Post Ledger Transactions via X++
Источник: http://daxguy.blogspot.com/2007/07/p...ons-via-x.html
==============

For beginner AX developers, I’m listing some codes which will help someone to post ledger transactions via X++ codes. This may be helpful to new Developers. [Level 200]

There are two ways to be considered when posting transactions:
1. Use the LedgerVoucher class and sub-classes API.
2. Use a journal Classes.

1. Use the LedgerVoucher class and sub-classes API.

The Classes are:
• LedgerVoucher - Posting {LedgerVoucher harnesses the posting of multiple vouchers at a time. }
• LedgerVoucherObject - Voucher {The LedgerVoucher class holds all the vouchers in temporary storage.}
• LedgerVoucherTransObject – Transactions {Holds transactions in each Voucher}

Instantiation of LedgerVoucher

LedgerVoucher::newLedgerPost(_detailSummary,
_sysModule,
_voucherSeriesCode,
[_transactionLogType,
_transactionLogText,
_approveJournal,
_posting]);

Instantiation of LedgerVoucherObject

LedgerVoucherObject::newVoucher(_voucher,
[_transDate,
_sysModule,
_ledgerTransType,
_correction,
_operationsTax,
_documentNum,
_documentDate]);

Instantiation of LedgerVoucherTransObject

LedgerVoucherTransObject newCreateTrans(_ledgerVoucherObject,
_ledgerPostingType,
_ledgerAccount,
_dimension,
_currencyCode,
_amountCur,
_sourceTableId,
_sourceRecId,
[_qty,
_exchRate ,
_exchRateSecond,
_exchRatesTriangulation,
_markBridging ,
ProjLedger,
AmountMST ])

Sample Code
static void LedgerVoucherAPISample(Args _args)
{
LedgerVoucher _LedgerVoucher;
LedgerVoucherObject _LedgerVoucherObject;
LedgerVoucherTransObject _LedgerVoucherTransObject;
NumberSeq _NumberSeq;
Dimension _Dimension;

NumberSequenceCode _VoucherCode = 'Ledger_3';
LedgerAccount _Account = '110180';
LedgerAccount _OffsetAccount = '140270';
AmountCur _AmountCur = 12345.67;

ttsbegin;
_NumberSeq = NumberSeq::newGetVoucherFromCode(_VoucherCode);
_LedgerVoucher = LedgerVoucher::newLedgerPost(DetailSummary::Detail,
SysModule::Ledger,
_VoucherCode);
_LedgerVoucherObject = LedgerVoucherObject::newVoucher(_NumberSeq.voucher());
_LedgerVoucher.addVoucher(_LedgerVoucherObject);
_LedgerVoucherTransObject = LedgerVoucherTransObject::newCreateTrans(_LedgerVoucherObject,
LedgerPostingType::LedgerJournal,
_Account,
_Dimension,
CompanyInfo::standardCurrency(),
_AmountCur,
0,
0);
_LedgerVoucherTransObject.parmTransTxt("Arijit Basu");
_LedgerVoucher.addTrans(_LedgerVoucherTransObject);
_LedgerVoucherTransObject = LedgerVoucherTransObject::newCreateTrans(_LedgerVoucherObject,
LedgerPostingType::LedgerJournal,
_OffsetAccount,
_Dimension,
CompanyInfo::standardCurrency(),
_AmountCur*-1,
0,
0);
_LedgerVoucherTransObject.parmTransTxt("Arijit Basu");
_LedgerVoucher.addTrans(_LedgerVoucherTransObject);
_LedgerVoucher.end();

ttscommit;
}

2. Use a journal Classes.

The tables used are LedgerJournalName, LedgerJournalTable, and LedgerJournalTrans.
The steps are:
• Create a journal table record {Table\LedgerJournalTable}
• Create lines for each transaction to be posted {Table\LedgerJournalTrans}.
• Post the journal. {Classes\LedgerJournalCheckPost}

Sample Code

static void LedgerJournalCheckPostDemo(Args _args)
{
LedgerJournalTable _LedgerJournalTable;
LedgerJournalTrans _LedgerJournalTrans;
LedgerJournalCheckPost _LedgerJournalCheckPost;
NumberSeq _NumberSeq;

ttsbegin;
//----Journal Header
_LedgerJournalTable.JournalName = 'Day1';
_LedgerJournalTable.initFromLedgerJournalName();
_LedgerJournalTable.Name = 'Daily Journal';
_LedgerJournalTable.insert();
//----Journal Line
_NumberSeq =NumberSeq::newGetVoucherFromCode(LedgerJournalName::find(_LedgerJournalTable.JournalName).VoucherSeries);
_LedgerJournalTrans.Voucher =_NumberSeq.voucher();
_LedgerJournalTrans.JournalNum =_LedgerJournalTable.JournalNum;
_LedgerJournalTrans.CurrencyCode =CompanyInfo::standardCurrency();
_LedgerJournalTrans.ExchRate =Currency::exchRate(_LedgerJournalTrans.CurrencyCode);
_LedgerJournalTrans.AccountNum ='110180';
_LedgerJournalTrans.AmountCurDebit =1000;
_LedgerJournalTrans.TransDate =Today();
_LedgerJournalTrans.OffsetAccount ='140270';
_LedgerJournalTrans.Txt ='Arijit Basu :)';
_LedgerJournalTrans.insert();
//----Journal Posting
_LedgerJournalCheckPost =LedgerJournalCheckPost::newLedgerJournalTable(_LedgerJournalTable,NoYes::Yes);
_LedgerJournalCheckPost.run();
ttscommit;
Info(StrFmt("Journal %1 is posted",_LedgerJournalTable.JournalNum));
}

Happy DAXing :)



Источник: http://daxguy.blogspot.com/2007/07/p...ons-via-x.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Arijit Basu: AX 2009 Documents Blog bot DAX Blogs 0 30.08.2008 13:05
Arijit Basu: Microsoft Dynamics AX 2009 White Paper: Posting to the Ledger Blog bot DAX Blogs 1 04.08.2008 11:40
Arijit Basu: Copenhagen Convergence Review Blog bot DAX Blogs 3 07.11.2007 11:56
Dynamics AX: Microsoft Dynamics AX (DAX): Known Issues when upgrading to Microsoft Dynamics™ AX 4.0 - Arijit Basu | AX MVP Blog bot DAX Blogs 0 31.05.2007 03:30

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 16:25.