Skip to main content

X++ code to create & post General Journal

X++ code to create & post General Journal

Some time we need to generate a General Journal through X++ code rather than go to GL module. For eg. WE are creating a journal after completion of some particular condition.
Try following code to create a General Journal and than post in in the same code through X++.

static void theaxapta_CreateGLJournalPost(Args _args) 

AxLedgerJournalTable journalTable; // class
AxLedgerJournalTrans journalTrans; // class
container acctPattern; 
container offSetAcctPattern; 
LedgerJournalTable ledgerJournalTable; // table
ledgerJournalCheckPost ledgerJournalCheckPost;// table

journalTable = new AxLedgerJournalTable(); 
journalTrans = new AxLedgerJournalTrans(); 
//Journal Name 
journalTable.parmJournalName("GenJrn"); 
journalTable.save(); 
journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum); 
journalTrans.parmTransDate(systemDateGet()); 
journalTrans.parmCurrencyCode("USD"); 
journalTrans.parmAmountCurDebit(1200); 
journalTrans.parmAccountType(LedgerJournalACType::Ledger); 
acctPattern = ["21345-Disp","211345", 2, "Department","0000114","CostCenter", "0000087"]; 
journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern)); 
journalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger ); 
offSetAcctPattern = ["40100-Disp","40100", 4, "Department","0000114","CostCenter", "0000087", "CustomPurposeA","Nile", "CustomPurposeB", "Site1"]; 
journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern)); 
journalTrans.save(); 
ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes); 
ledgerJournalCheckPost.run(); 
info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum));
}

Comments

Popular posts from this blog

D365 : ENABLE AND DISABLE IN LIST PAGE

 here i have added 4 button in salesQuotationlistpage. now i need to enable/disable button according status. so i have Extensionof  of class SalesQuotationListPageInteraction and modify setButtonEnabled method by Chain of Command //list page button enable and diable in listpage interation class [ExtensionOf(classStr(SalesQuotationListPageInteraction))] final class SQTableinimathod_Extension {     protected void setButtonEnabled()     {                SalesQuotationTable SalesQuotationTable;         CustQuotationJour   CustQuotationJour;         CustQuotationConfirmJour  CustQuotationConfirmJour;               next setButtonEnabled();         SalesQuotationTable SalesQuotationTable1 = this.listPage().activeRecord(queryDataSourceStr(SalesQuotationListPage, SalesQuotationTable));         selec...

An error occurred during report data sets execution D365 For finance and operations

  Hi all, small tip. I faced this issue, when I extend the custom report in D365 for finance and operations. During development on onebox     Solution was simple, restart IIS services Restart Reporting Services. Happy Daxing.

CODE TO PDF IN AX 2012

static void Job1(Args _args) {         PurchPackingSlipController      ssrsController = new SrsReportRunController();         TradeDocumentReportContract     purchPackingSlipContract = new TradeDocumentReportContract();         SRSPrintDestinationSettings     printerSettings;         VendPackingSlipJour             VendPackingSlipJour;         Args                            args;         //select the latest record based on create date         while select VendPackingSlipJour             order by VendPackingSlipJour.createdDateTime DESC             where VendPackingSlipJour.PackingSlipId == 'LJ-01'         ...