Use of TextIO

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

Write

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);
file.outFieldDelimiter(";");
value += _value;
file.write(value);
super();
}

Read

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

AX 2012 – Editor wizard statement

Just a little tips over the editor with the try/catch statement.
Begin to write “try”
Press “tabulation” and you will receive the result below
You cursor will be put in the try statement.
I just try it with the “if”, “else” and “switch” statement, that’s work also.

AX 2012 – Editor wizard for "parm" method

You maybe know already it, but I discover it today.
When you create a new method, you delete all caracter in the method, and juste write “parm” and after press “Tabulation”.
You will have a popup for create a parm method.
BUT
This wizard is limited to EDT parm method :-(

You can’t create a parm method who return a table, you must use the old method :-) : from scratch.

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)
{
#WinAPI

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

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

process = new System.Diagnostics.Process();

processStartInfo = new System.Diagnostics.ProcessStartInfo();
processStartInfo.set_FileName(@"C:\WINDOWS\System32\ftp.exe");
processStartInfo.set_Arguments(_fileName);
processStartInfo.set_WorkingDirectory(_localFolder);

process.set_StartInfo(processStartInfo);

process.Start();

//process.WaitForExit();
process.Close();
}

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.
Solution:
  • Stop your production AOS
  • Start test AOS
  • Start production AOS again.

Included columns in Dynamics AX 2012

You will find the link who explain the process :
Little part of the post:
Included columns is a feature of SQL Server (since version 2005) related to indices.Thanks to it you can attach additional fields to an index that are not used for searching (so they don’t have to be maintained so expensively) but that can be used by database server to return data. If all columns being returned by a query are included in an index, database server can directly return data and it doesn’t have to touch the table itself (and that saves time, of course).
Included columns also have additional advantages:
  • can be added to a unique index without influencing uniqueness
  • support even (some) types that can’t be used in normal indices
  • don’t count to the limit of number of index columns (16)
  • don’t count to the limit of index size (900 bytes)
The following (logical) restriction apply:
  • are always at the end of index
  • the index must contain at least one “normal” (key) column
  • can’t be used in clustered indices
Of course, even included columns have impact to index size so they can slow down operations with the index and consume disk space.