Tuesday, 7 January 2014

Processing a project journal in ax 2012 through X++

1.In the AOT, create a new job named ProjJournalCreate with the following code:

static void ProjJournalCreate(Args _args)
{
ProjJournalTable jourTable;
ProjJournalTrans jourTrans;
ProjJournalTableData jourTableData;
ProjJournalTransData jourTransData;
ProjJournalStatic jourStatic;
ttsBegin;
jourTableData = JournalTableData::newTable(jourTable);
jourTable.JournalId = jourTableData.nextJournalId();
jourTable.JournalType = ProjJournalType::Hour;
jourTable.JournalNameId = 'Hours';
jourTableData.initFromJournalName(
ProjJournalName::find(jourTable.JournalNameId));
jourStatic = jourTableData.journalStatic();
jourTransData = jourStatic.newJournalTransData(
jourTrans,
jourTableData);
jourTransData.initFromJournalTable();
jourTrans.initValue();
jourTrans.ProjId = '10001';
jourTrans.initFromProjTable(
                ProjTable::find(jourTrans.ProjId));
jourTrans.TransDate = systemDateGet();
jourTrans.ProjTransDate = jourTrans.TransDate;
jourTrans.CategoryId = 'Design';
jourTrans.setHourCostPrice();
jourTrans.setHourSalesPrice();
jourTrans.TaxItemGroupId =
ProjCategory::find(jourTrans.CategoryId).TaxItemGroupId;
jourTrans.Worker =
HcmWorker::findByPersonnelNumber('000062').RecId;
jourTrans.Txt = 'Design documentation';
jourTrans.Qty = 8;
jourTransData.create();
jourTable.insert();
ttsCommit;
info(strFmt(
"Journal '%1' has been created", jourTable.JournalId));
}

2. Run the job and check the results by going to Project management and accounting | Journals | Hour:

No comments:

Post a Comment

SQL/SSRS Interview questions I thought of blogging some SQL/SSRS interview questions.

Below are some. I will add more, when I complete the compilation 1. What is OLTP(Online Transaction Processing)? OLTP stands ...