Friday, October 20, 2023

Code to create a AP invoice journal in D365F&O X++

public static void main(Args _args)

   {

       MCRLedgerJournal        journalTable;

       LedgerJournalTable      ledgerJournalTable;

       Counter                 recordsInserted;

        ttsbegin;

       //Creates the journal header table

       journalTable = new MCRLedgerJournal_VendInvoiceRegister(LedgerJournalType::VendInvoiceRegister,"APInvoice");

       ledgerJournalTable = journalTable.createLedgerJournalTable();

       journalTable.parmLedgerJournalTable(ledgerJournalTable);

       journalTable.parmMCRCCGeneralLedgerId();

       journalTable.parmCurrencyCode(CompanyInfoHelper::standardCurrency());

 

       // creates a new line in general journal

       journalTable.parmLineNum();

       journalTable.parmLedgerAccountType(LedgerJournalACType::Vend);

       journalTable.parmLedgerAccount(LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber("1001",LedgerJournalACType::Vend)); //You need to use the vendor account as per your environment's data.

       journalTable.parmTransDate(today());

       journalTable.parmTransTxt("Acquisition");

       journalTable.parmInvoice("123");

       journalTable.parmExchRate(0.00);

       journalTable.createLedgerJournalTrans(abs(0),abs(100),LedgerJournalACType::Vend);

       recordsInserted++;

       ttscommit;

       info(strFmt("Journal number %1 is created", ledgerJournalTable.JournalNum));

   }

 ...............


AP>Invoices>Invoice Journal





No comments:

Post a Comment