static void Create_XML(Args _args)
{
XmlDocument doc;
XmlElement nodeXml;
XmlElement nodeTable;
CustTrans _custTrans;
#define.filename(@"D:\Output\TEST_CREATE.xml")
;
doc = XmlDocument::newBlank();
nodeXml = doc.createElement('CustomerVoucher');
doc.appendChild(nodeXml);
while select * from _custTrans
where _custTrans.AccountNum == '10002'
{
nodeTable = doc.createElement('DocumentNumber');
nodeXml.appendChild(nodeTable);
nodeTable.appendChild(doc.createTextNode(_custTrans.DocumentNum) );
nodeTable = doc.createElement('VoucherNumber');
nodeXml.appendChild(nodeTable);
nodeTable.appendChild(doc.createTextNode(_custTrans.Voucher) );
}
doc.save(#filename);
}
Tuesday, July 6, 2021
Create XML with data from CustTrans table
Create LedgerJournalTrans with Marked Settlement Vendor for AX 2009
static void Create_AP_JournalSettlement_AX(Args _args)
{
/** Add Ledger type : Vendor lines with marking of open vendor transaction to existing Journal Table for AX 2009 **/
/** Using custom class to create LedgerJournalTrans **/
LedgerJournalTrans _ljt, _ljt2;
VendTransOpen _vto;
VendTrans _vt;
CustVendOpenTransManager manager;
container conVchx;
JournalId jourNumx;
TransDate transDatex, docDatex, dueDatex;
Amount totSettledx;
Str 20 invoiceNumx;
RecId ljtRecIdx;
AccountNum accNumx;
;
jourNumx = '20-0002940';
transDatex = today();
invoiceNumx = '12345';
accNumx = 'V0008';
if(!LedgerJournalTable::find(jourNumx).Posted)
{
delete_from _ljt where _ljt.JournalNum == jourNumx;
}
_ljt = AX_LedgerJournal::createJournalLines(jourNumx, '', transDatex, docDatex, dueDatex,
'Vendor',accNumx,0,0,'Ledger','','','','','','1.PRO');
ljtRecIdx = _ljt.RecId;
manager = CustVendOpenTransManager::construct(_ljt);
manager.resetMarkedTrans();
while select * from _vto
join Invoice from _vt
where _vto.RefRecId == _vt.RecId
&& _vto.AccountNum == _vt.AccountNum
&& _vt.AccountNum == accNumx
&& _vt.Invoice == _invoiceNumx
{
manager.updateTransMarked(_vto, true);
totSettledx = manager.getMarkedTotalDisplayCur();
info(strfmt('%1 %2 %3', _vto.AccountNum, _vt.Invoice, totSettledx));
}
ttsBegin;
_ljt.MarkedInvoice = '';//ctcheck.Invoice;
_ljt.SettleVoucher = SettlementType::SelectedTransact;
_ljt.Txt = strfmt('Invoicing %1',transDatex);
//_ljt.DocumentNum = strfmt('%1',invoiceNumx);
if(totSettledx > 0)
{ _ljt.AmountCurCredit = abs(totSettledx); }
else
{ _ljt.AmountCurDebit = abs(totSettledx); }
_ljt.update();
ttsCommit;
_ljt2 = AX_LedgerJournal::createJournalLines(jourNumx, _ljt.Voucher,transDatex, docDatex, dueDatex,
'Vendor',accNumx,0,abs(totSettledx),'Ledger','','',invoiceNumx,'',_ljt.Txt, '2.INV');
}