Wednesday, April 1, 2015

Creating Genral Journal using X++ in AX 2012

static void LedgerJournalCreate(Args _args)
{
LedgerJournalTable jourTable;
LedgerJournalTrans jourTrans;
LedgerJournalTableData jourTableData;
LedgerJournalTransData jourTransData;
LedgerJournalStatic jourStatic;
DimensionDynamicAccount ledgerDim;
DimensionDynamicAccount offsetLedgerDim;

ttsBegin;

ledgerDim =
DimensionAttributeValueCombination::getLedgerDimension(
'110180',
['Department', 'CostCenter', 'ExpensePurpose'],
['OU_2311', 'OU_3568', 'Training']);

offsetLedgerDim =
DimensionAttributeValueCombination::getLedgerDimension(
'170150',
['Department', 'CostCenter', 'ExpensePurpose'],
['OU_2311', 'OU_3568', 'Training']);

jourTableData = JournalTableData::newTable(jourTable);
jourTable.JournalNum = jourTableData.nextJournalId();
jourTable.JournalType = LedgerJournalType::Daily;
jourTable.JournalName = 'GenJrn';
jourTableData.initFromJournalName(
LedgerJournalName::find(jourTable.JournalName));
jourStatic = jourTableData.journalStatic();
jourTransData = jourStatic.newJournalTransData(
jourTrans,
jourTableData);
jourTransData.initFromJournalTable();
jourTrans.CurrencyCode = 'USD';
jourTrans.initValue();
jourTrans.TransDate = systemDateGet();
jourTrans.LedgerDimension = ledgerDim;
jourTrans.Txt = 'General journal demo';
jourTrans.OffsetLedgerDimension = offsetLedgerDim;
jourTrans.AmountCurDebit = 1000;
jourTransData.create();
jourTable.insert();

ttsCommit;
info(strFmt(
"Journal '%1' has been created", jourTable.JournalNum));
}

No comments:

Post a Comment

How to enable the dimension fields based on the Item selected on the form.

[Form] public class KMTShipFromWarehouses extends FormRun {     InventDimCtrl_Frm_EditDimensions        inventDimFormSetup;     /// ...