hljs.configure({cssSelector: "code"}); hljs.highlightAll();

Wednesday, August 19, 2020

General Journal Creation and Posting in AX 2012 Using X++

 static void GeneralJournalCreate(Args _args)

{

    //class for journal header creation

    AxLedgerJournalTable   axLedgerJournalTable ; 

    //class for journal lines creation

    AxLedgerJournalTrans   axLedgerJournalTrans;  

    container              accPattern;    

    container              offSetPattern;

    // class for journal  posting

    ledgerJournalCheckPost ledgerJournalCheckPost; 

    axLedgerJournalTable = new AxLedgerJournalTable();

    axLedgerJournalTrans = new AxLedgerJournalTrans();

    // Journal Header creation

    axLedgerJournalTable.parmJournalName("GenJrn");

    axLedgerJournalTable.save();     

    // Journal lines Creation

    axLedgerJournalTrans.parmJournalNum(axLedgerJournalTable.ledgerJournalTable().JournalNum);

    axLedgerJournalTrans.parmTransDate(systemDateGet());

    axLedgerJournalTrans.parmAmountCurDebit(300);

    //axLedgerJournalTrans.parmAmountCurcredit(300);

    axLedgerJournalTrans.parmAccountType(LedgerJournalACType::Ledger);

    // 2-indicates no of financial dimension values

    // 110110- main account id and dispaly name

    accPattern = ['110110','110110',2,'BusinessUnit',"001","Department","022"];

    axLedgerJournalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(accPattern));

    offSetPattern = ['112140',"112140",2,'BusinessUnit','003',"Department","024"];

    axLedgerJournalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetPattern));

    axLedgerJournalTrans.save();

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

    // Journal Posting

    ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(axLedgerJournalTable.ledgerJournalTable(),NoYes::Yes);

    ledgerJournalCheckPost.run();

    info(strFmt("Journal No. %1.", axLedgerJournalTable.ledgerJournalTable().JournalNum));

}


  

No comments:

Post a Comment