Select query by using connection class Monday, Jan 19 2009 

query in standard Axapta is really limited because I can’t define distinct. Here is the code to define it, but as a note, you need to define it as a server run object.

public client server static void GetBatchListed( itemId _ItemId)


    Connection  conn;

    Statement   stmt;

    ResultSet   R;

    SqlStatementExecutePermission perm;

    str         sql;

    TSWrkInventBatch    TSWrkInventBatch;


    conn = new connection();

    stmt = conn.createStatement();

    sql = “select * from InventBatch IB inner join (“;

    sql += “select distinct c.InventBatchId from Inventsum a inner join InventDim b “;

    sql += “on a.Inventdimid = b.inventdimid “;

    sql += “inner join InventBatch c on b.InventBatchId = c.InventBatchId “;

    sql += “where a.ItemId = %1 and “;

    sql += “c.inventBatchId <> ”) as TBJoin on IB.InventBatchId = TBJoin.InventBatchId”;

    perm = new SqlStatementExecutePermission(strfmt(sql,_ItemId));


    R = Stmt.executeQuery(sql);

    while (


        info( R.getString(fieldnum(InventBatch, InventBatchId)));




Hierarchy Clustering Algorithm Thursday, Jan 8 2009 

Huum, for a while I write a note to define Single Linkage Clustering Algorithm..
Well, I’m afraid I forget it or lose my note, so I’d like to write it here..

From data scratch, I need to redefine it into distance matrix..
//distance matrix
for i=1 to row
for j = i+1 to row
Mat[i,j] = Euclid(Data[i], Data[j])


then I need to find the minimum for each data point, and restore it into temporary variable
//run single linkage clustering
while 1
min = 0
for i = 1 to row
for j = i+1 to row
if min > Mat[i,j] and Mat[i,j] >= 0 then
min = Mat[i,j]
Dtx = i; Dty = j //store the row column that has minimum distance


MatH[Dtx, Dty] = min;
Mat[Dtx, Dty] = -1;
//it means, condition never meet the minimum value, because all value has already -1
if mean = 0 then


Hope it will run well 🙂

Update in Axapta Thursday, Dec 11 2008 

I’ve learned axapta for 2 days and I found a wall while customized it :p
Actually, it’s really different with Solomon, you could not just select or update like sql script. Here’re the scripts:

while select forUpdate wmsorder where wmsorder.inventTransId == salesline.InventTransId
select * from inventtable where inventtable.ItemId == salesline.ItemId;

if (inventtable)
wmsorder.itemName = inventtable.itemName;
wmsorder.PortDest = salestable.Port;

ttsbegin and ttscommit are like tranbeg and tranend in Solomon. This code makes sure your table is in update condition, and the system will wait until your update process finish.

Redim Preserve di C# Tuesday, Oct 14 2008 

Karena sempat merasa bosan dengan coding di VB, last few days saya coba” coding di C# 🙂 dan ternyata jauh lebih bebas coding di C# ketimbang di VB. But, sempet bingung dengan how to define redim preserve in c#, and finally I did it. Below is the example code.

string[] MyArray;
string[] temp;

for (i=0;i<length;i++)
temp = new string[i + 1];
if (MyArray != null)
    Array.Copy(MyArray, temp, Math.Min(MyArray.Length, temp.Length));
MyArray = temp;

How to define day name in SQL Server Thursday, Sep 4 2008 

The SQL function that you could use is datename(datepart, date). Datepart is kind of properties that you’d like to use. For example, dw is kind of datepart to define week day, or mm to define month name. Here is the example

select datename(dw, getdate())

The result is


You could try others datepart such as dw, mm, dy, wk, ww. Have a nice try 🙂

Shortcut to faster login (SL 7.0 SP1) Wednesday, Sep 3 2008 

There’s a weakness of SL 7.0 SP1 when I’d like to login while I used the different server as current in the last login. Let’s say I’m using ‘SL7Server’ as server name for the first time, and then I’m going back home and would like to continue my work, which is my local server name is different with the latest server name I’ve used. There’s a problem with time when I’d like to login. It really takes time when SL trace the latest server name as default. I’ve ever waited it for 20 minutes and there was nothing.

The shortcut way to make it faster is deleting the solomon.ini file in C:\Documents and Settings\[my windows login name]\Local Settings\Application Data\Microsoft Dynamics SL.  I’ve tried it and it worked :), SL will create a new solomon.ini file after the re-login.

« Previous PageNext Page »