Ax 2012 Arrays

An array is a collection of variables that are all of the same type. The elements of an array are accessed with simple integer indexes.

There are three kinds of arrays:

  • Dynamic
  • Fixed-length
  • Partly on disk

X++ only supports one-dimensional arrays. It is possible, however, to mimic the behavior of multiple array indices.

Example JOB:

static void ArrayTypes(Args _args)
{
Name DynamicArray[];
Name FixedArray[4];
//Name PartllyOnDiskArray[,8]; // if you use like this then it is Dynamic array of Name only 8 in memory
Name PartllyOnDiskArray[16,8];// if you use like this then it is Fixed length array of Name wit 16 elements and 8 in memory

int i,j;
 CustTable custTable;
 ;

while select AccountNum from custTable
where custTable.CustGroup==”30″
{
i++;
DynamicArray[i] = custTable.AccountNum;

if(i<=4)
FixedArray[i] = custTable.AccountNum;

PartllyOnDiskArray[i] = custTable.AccountNum;

}
setPrefix(“Array Types”);
setPrefix(“FixedArray”);
for (j=1;j<=dimOf(FixedArray);j++)
{
info(strFmt(“Fixed Array – %1”,FixedArray[j]));
}
setPrefix(“Dynamic Array”);
for (j=1;j<=dimOf(DynamicArray);j++)
{
info(strFmt(“Dynamic Array – %1”,DynamicArray[j]));
}
setPrefix(“PartlyOnDisk Array Memory value”);
for (j=1;j<=dimOf(PartllyOnDiskArray);j++)
{
info(strFmt(“PartlyOnDisk Array – %1”,PartllyOnDiskArray[j]));
}
setPrefix(“PartlyOnDisk Array fully printed (Disk + Memory)”);
for (j=1;j<=16;j++)
{
info(strFmt(“PartlyOnDisk Array – %1”,PartllyOnDiskArray[j]));
}

}

How can we validate our Customised/Standard( not in existing validation) field during Journal(Count & PL) validation and posting in Ax

Requirement:

When the journal is validated or posted from the post button on inventory journal or lines button on journal lines, inventory form, ensure that all the lines have adjustment code filled-in. if not, don’t post the journal and inform the user

Solution: apply the business logic in these class methods

## For Counting journal:

\Classes\InventMov_Jour_Loss_SumUp\journalCheckTrans()

## For Profit Loss journal:

*First override the method — journalCheckTrans

\Classes\InventMov_Jour_LossProfit\journalCheckTrans()

## In General

\Classes\JournalCheckPost\checkJournal()