Job to delete un-posted journals in Ax 2009

Simple job to delete un-posted journals in Ax 2009

    LedgerJournalTable  LedgerJournalTable;
    LedgerJournalTrans  LedgerJournalTrans;
    Container           journalList = [['DAT','JN-011111']];
    str 10              company,journalnum;
    int                 i;
    ;
    for(i=1; i <= conlen(journalList); i++)
    {
        [company, journalnum] = conpeek(journalList,i);
        info(strfmt("%1 - Company: %2, JournalNum: %3", 1, company,journalnum));

        changecompany(company)
        {
            LedgerJournalTrans = null;
            LedgerJournalTable = null;

            ttsbegin;
            delete_from LedgerJournalTrans
                where LedgerJournalTrans.JournalNum == journalnum;
            delete_from LedgerJournalTable
                where LedgerJournalTable.JournalNum == journalnum;
            ttscommit;
            info(strfmt("Recid after deletion: %1", LedgerJournalTable::find(journalnum).RecId));
        }
    }
    info("Execution completed");

Comments

Popular posts from this blog

Dynamics 365 Finance & Operations Release pipelines import.

Attaching a user selected document to a purchase order using x++ job (Runnable class) in Dynamics 365 for Finance and Operations

Claude AI Models Comparison (Updated: July 2026): Haiku 4.5 vs Sonnet 5 vs Opus 4.8 vs Fable 5