Monday, December 23, 2013

Creating Journal using X++ code

static void CreatingGLJournaltoVendorinAx2012(Args _args)
{
    AxLedgerJournalTable header = new AxLedgerJournalTable();
    AxLedgerJournalTrans trans = new AxLedgerJournalTrans();
    container  ledgerDimensions;
    DimensionDynamicAccount     offsetDimensions;
    Args    args;

    //Journal
    header.parmJournalName("GenJrn");
    header.save();

    // Creating  a ledger account
    trans.parmAccountType(LedgerJournalACType::Ledger);
    trans.parmJournalNum(header.ledgerJournalTable().JournalNum);
    ledgerDimensions = ["601501-US","601501", 0];
    trans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(ledgerDimensions));
    trans.parmAmountCurDebit(230);

    //Creating an offset account
    offsetDimensions =  DimensionStorage::getDynamicAccount('3008', LedgerJournalACType::Vend);
    trans.parmOffsetLedgerDimension(offsetDimensions);
    trans.parmOffsetAccountType(LedgerJournalACType::Vend);
    trans.save();
    info(strFmt("Journal %1 created",  header.ledgerJournalTable().JournalNum));
   
    args = new Args();
    args.record(LedgerJournalTable::find(header.ledgerJournalTable().JournalNum ));

    new MenuFunction(MenuItemDisplayStr(LedgerJournalTable),MenuItemType::Display).run(args);
}

No comments:

Post a Comment