Using #localmacro

Using the option #localmacro can reduce the size and also the visibility of your code.

For example, you create a while select statement and you have to control date range when some value are enable (so not all the time)

You can write this kind of code :

protected void doProcess()
        (salesTable.DeliveryDate >= fromDate && salesTable.DeliveryDate <= toDate)

        (custPackingSlipJour.DeliveryDate >= fromDate && custPackingSlipJour.DeliveryDate <= toDate)

    while select salesTable
    where (!validatedOrTransmited   || ((salesTable.MySalesStatus    == MyStatus::Transmission
                                    ||   salesTable.MySalesStatus    == MyStatus::Validation))
    && #CheckDateDelivery)
    &&    (!prepared                ||  (salesTable.MySalesStatus    == MyStatus::Prepare
    && #CheckDateDelivery))
    &&    (!delivered               ||  (salesTable.MySalesStatus    == MyStatus::Delivery))
    exists join firstOnly custPackingSlipJour
    where   custPackingSlipJour.SalesId == salesTable.SalesId
    &&     (!delivered  || #CheckDateDocument)
        // code here.

Use of TextIO

There is a little simple example of “How to use the TextIO” classes.


public void writeOnFile(FileName _fileName, str _value)
boolean first = true;
container value;
TextIO file;

//add to the end of the file
//file = new AsciiIO(_fileName, #io_append);
//create a new file
file = new AsciiIO(_fileName, #io_write);
value += _value;


private void importFile(FileName _fileName)
TextIO file = new TextIO(_fileName, #io_read);
if (!file || file.status() != IO_Status::Ok)
throw error("Can't open file"); }
line =;
while (conLen(line))
// Your code
line =;
file = null;

Shell execute on batch server

There below the code for simulate a ShellExecute method for the Batch, because, as you have certainly see, we can’t execute the standard WinAPI::execute() method.
I make my example with the FTP command.
server static void shellExecuteFTP(Filename _fileName, str _localFolder)

System.Diagnostics.Process process;
System.Diagnostics.ProcessStartInfo processStartInfo;

new InteropPermission(InteropKind::ClrInterop).assert();

process = new System.Diagnostics.Process();

processStartInfo = new System.Diagnostics.ProcessStartInfo();




Posted in AX5

Object Server 02: Concurrent number of AOS’ for this application exceeds the licensed number.

I receive this error. There below the solution to launch your AOS.
I have next situation: I create a copy of my production database and restore it to my test database. Then I try to start my second test AOS (stopped to allow restore of db):
Object Server 02: Concurrent number of AOS' for this 
application exceeds the licensed number.
  • Stop your production AOS
  • Start test AOS
  • Start production AOS again.

Change company

You can use the statement “changeCompany”
But when you want open a new form into another company, it’s a better to choice this peace of code:

boolean promptChangmentOfCompany = false;
appl.setDefaultCompany(_companyId, promptChangmentOfCompany);

Posted in AX5

Show dimension in a new form

Show the dimension of an item in a new form with new table. Your form must contain the datasource InventDim linked to your table with the InventDimId. 
Set the properties of your table like this :
You must add the InventtoryDimensionGroup (copy from SalesTable for example)
Add a new button in the form from the MenuItemDisplay  InventDimParmFixed
After that, in the classDeclaration :
public class FormRun extends ObjectRun()
InventDimCtrl_Frm_activeRightClick inventDimFormSetup;
Create the following methods:
Object inventDimSetupObject()
return inventDimFormSetup;
void updateDesign(InventDimFormDesignUpdate _mode)
InventDimParm inventDimParm;

switch (_mode)
case InventDimFormDesignUpdate::Init :
if (!inventDimFormSetup)
inventDimFormSetup = InventDimCtrl_Frm_activeRightClick::newFromForm(element);
And now, modify your init() method:
public void init()