Microsoft Dynamics Ax developer's blog

Friday, January 26, 2007

Dynamic analog of abstract macro

Palle Algemark have published an article witch solution of the same task which have been solved by abstract macro in my latest post. He uses table map and reflection code to achieve flexibility.

It is good, especially when you have ready to use map for all concrete tables. It is more difficult to create such map id you haven't.

For example you can not just declare fact, that you have same name for a field in each table; uou should: either repeatedly add declaration of all field mappings, or generate it by reflection code, or generate it in xpo.

The following dynamic code uses only list of tables and the fact, that ItemID has the same name:

static void Test_DictTab(Args _args)
container tables = [
int i;

void processTable(TableID _tableID)
SysDictTable table = SysDictTable::newTableId(_tableID);
Common record = table.makeRecord();
FieldID itemField = table.fieldName2Id(fieldStr(InventTable, ItemID));
while select count(recID) from record
where record.(itemField) == '001'
info(strFmt("%1 = %2", table.label(), record.RecId));
for(i=1; i<=conLen(tables); i++)
processTable(conPeek(tables, i));

Thursday, January 25, 2007

Abstract macro

Recently published article about trick, whch I have often used in BAAN and sometimes in Dynamics Ax programming.

read the article at Axaptapedia

Two days ago I have added a new inventory dimension and was impressed how many work can be eliminated using this trick...

But don't overuse macros in can lead to less readability of your code.

One time I have used macros to build something like internal DSL to describe mapping of Ax tables to interface tables on SQL server and now one my ex-collegue claim it is unreadable.

Tuesday, January 16, 2007

Tabax 0.2.13

what's new
Summary: open application object for the currently selected item in AOT, some managebility and extensibility.

Monday, January 15, 2007

WordSL - Microsoft Word as a visual XSLT editor

Just uploaded a varsion of the WordSL - tool which lets generate Word 2003 xml files via XSLT - you don't even need to have a word on a server to provide a file generation.


Thursday, January 04, 2007

customization: do it smarter

If you haven't watched the video Dynamics AX 4.0 - Smart customizations - watch it! (especally if you are novice Dynamics Ax developer).

I can just add few thoughts:

First of all - this sceencast recommends to subclass existing class, but i thing there asre some cases when it is better to tweak existing class. The most often case - when existing class has bad structure (for example LedgerJournalCheckPost in 3.0 - i don't know about 4.0 so much). If you have one large method which does all you can not just overide it to add some functionality - you often have to copy all it's body to the child and tweak it. I you do so you will have more problems when upgrading to the next version: you have not only to upgrade method of existing parent, but to modify all copied parts of the child and there is no obvious clues to find what parts to modify.

Second, what can be done to make upgrades less painful:

  • Interfaces - there havte to be more documented interfaces - so Ax devs will know what they can change and what cannot to make Ax backward compatible.
  • Unit tests as part of Ax package - all unit tests developed by Ax team have to be shipped with Ax to enable partner or customer developers ensure they haven't breaked anything
  • Events - SAP R/3, as i know, have concept of events - you have not to modify existing code to be informed about some thing ocuured in system - you just subscribe, say, to journal posting and can make extra transaction if you want. So your customisation code isn't mixed with the existing code.
  • Better code structure - i think there is no excure for very big methods for example. Better code structure can be easy reused by customer programmers and can be seft documented and testable.