Wednesday, December 14, 2011

Sometimes AX doesn't work as expected even if changes has been made to a code. Here are some suggestions

Compile

Compile and recompile.

License

While coding in a class, make sure that you have a x++ license, otherwise every changes made to a class will not be used.

Close the debugger
Sometimes, when the debugger is active, AX will keep executing ‘old’ code. Close the debugger to make sure the latest code is executing.

Synchronize data dictionary

Open the specific tables and synchronize or if everything else fails, just synchronize the whole AOT.

Restart AX

Simple as that, close the AX client and start it again.

Reset usage data
Go to options screen (AX button > Extra > Options) and click the Usage Data button. Click reset to remove this data.

Check the application event log for clues
Open the event viewer on the AOS to see if the AOS service has logged something in it. Messages here can help you a great deal. You can also check the event log on the database server or your client pc.

Delete AUC file

The application Unicode object cache file, if there is one, is located at C:\Documents and Settings\[USERNAME]\Local Settings\Application Data for xp, or C:\Users\USERNAME\AppData\Local for vista. Delete this file while the AX client is closed.

Full compile

Restart AOS

Remove .aoi file


Thursday, December 8, 2011

New Line in Report

To add a line break in Dynamics AX report, just add the character '\n' to a String and make sure that its label's Dynamic Height in Dynamics AX report is set to "Yes"

Monday, December 5, 2011

Terbilang Function in Dynamics Ax in Indonesian

static TempStr numeralsToTxt_Indo(Real _num)
{
int numOfPennies = frac(_num)*100 mod 100;
int test = round(_num,0);

int numOfTenths;
str 20 ones[19], tenths[9], hundreds, thousands, millions, billions;

int temp;
str 200 returntxt;

int checkPower(int _test, int _power)
{
int numOfPower;

if (_test >= _power)
{
numOfPower = _test DIV _power;
if (numOfPower >= 100)
{
temp = numOfPower DIV 100;
returntxt = returntxt + ' ' + ones[temp] + ' ' + hundreds;
numOfPower = numOfPower MOD 100;
}
if (numOfPower >= 20)
{
temp = numOfPower DIV 10;
returntxt = returntxt + ' ' + tenths[temp];
numOfPower = numOfPower MOD 10;
}
if (numOfPower >= 1)
{
returntxt = returntxt + ' ' + ones[numOfPower];
numOfPower = numOfPower MOD 10;
}
switch(_power)
{
case 1000000000 :
{
returntxt = returntxt + ' ' + billions;
_test = _test MOD 1000000000;
break;
}
case 1000000 :
{
returntxt = returntxt + ' ' + millions;
_test = _test MOD 1000000;
break;
}
case 1000 :
{
returntxt = returntxt + ' ' + thousands;
_test = _test MOD 1000;
break;
}
case 100 :
{
returntxt = returntxt + ' ' + hundreds;
_test = _test MOD 100;
break;
}
}
}
return _test;
}



ones[1] = "Satu";
ones[2] = "Dua";
ones[3] = "Tiga";
ones[4] = "Empat";
ones[5] = "Lima";
ones[6] = "Enam";
ones[7] = "Tujuh";
ones[8] = "Delapan";
ones[9] = "Sembilan";
ones[10] = "Sepuluh";
ones[11] = "Sebelas";
ones[12] = "Dua Belas";
ones[13] = "Tiga Belas";
ones[14] = "Empat Belas";
ones[15] = "Lima Belas";
ones[16] = "Enam Belas";
ones[17] = "Tujuh Belas";
ones[18] = "Delapan Belas";
ones[19] = "Sembilan Belas";

tenths[1] = 'Not used';
tenths[2] = "Dua Puluh";
tenths[3] = "Tiga Puluh";
tenths[4] = "Empat Puluh";
tenths[5] = "Lima Puluh";
tenths[6] = "Enam Puluh";
tenths[7] = "Tujuh Puluh";
tenths[8] = "Delapan Puluh";
tenths[9] = "Sembilan Puluh";

hundreds = "Ratus";
thousands = "Ribu";
millions = "Juta";
billions = "Miliar";


test = checkPower(test, 1000000000);
test = checkPower(test, 1000000);
test = checkPower(test, 1000);
test = checkPower(test, 100);

if (test >= 20)
{
numOfTenths = test DIV 10;
returntxt = returntxt + ' ' + tenths[numofTenths];
numOfTenths = numOfTenths MOD 10;
test = test MOD 10;
}
if (test >= 1)
{
numOfTenths = test;
returntxt = returntxt + ' ' + ones[numOfTenths];
}

if (numOfPennies)
{
//returntxt = '***' + returntxt + ' ' + "@SYS5534" + ' ' + num2str(numOfPennies,0,0,0,0) + '/100';
//returntxt = returntxt + ' ' + num2str(numOfPennies,0,0,0,0) + '/100';
returntxt = returntxt + numeralstotxt_indo(numofpennies) + ' Sen';


}

if (strscan(strltrim(returntxt),"Satu Ribu",1,15)==1)
{
returntxt = strReplace(returntxt, "Satu Ribu", "Seribu");
}

returntxt = strReplace(returntxt, "Juta Satu Ribu", "Juta Seribu");
returntxt = strReplace(returntxt, "Satu Ratus", "Seratus");
return returntxt;
}