AXBC Classes in Axapta (Axapta Business Component Classes)
Ax
/AxBC classes
The Ax class is an X++ class that wraps a table to track state. An example of an Ax class is AxLedgerJournalTable. All Ax classes derive from the AxInternalBase class. From a service perspective, it is important to understand which elements that the consumer has passed to the service, so proper defaulting can occur. Ax classes share three common characteristics.
They contain generated 'parm' methods that wrap all the fields on the table. When an incoming message is deserialized, the service infrastructure invokes each 'parm' method for which the consumer passed data. These 'parm' methods then set state and update the database table. Therefore, after deserialization, the class maintains the elements that the consumer passed to the service. This allows field defaulting to use the values the consumer passed.
In general, the generated 'parm' methods are sufficient because they are only tracking state. In some cases, the value that you want to expose externally from the service is different than the internal value. Currency code is one example. Externally, you may want to use the ISO 4217
The generated 'set' methods are designed to be the place where the defaulting logic should be added. However, this approach keeps the defaulting logic inside the Ax class. We recommend that you do not implement defaulting logic in the 'set' methods. The code to determine the default value is typically the same in the service context and the interactive client context. Detailed recommendations for defaulting code are provided later in the document.
The setTableFields method is called by the service infrastructure after deserialization has occurred. This is where you should put your defaulting code.
Do remove the generated set methods.
Do keep the generated setTableFields method, but remove its individual calls to the this.set methods.
Do consider fields that should be translated into corresponding external values.
Do not create class hierarchies of Ax classes to implement defaulting variations because this application code is locked into these classes.
AX is throwing me this best pratice error , I dont know how to fix it.
The Table.Field does not have a corresponding parm-method on the AxBC-class
This is caused by new BP rules introduced in 5.0. These parm/exists methods
are used by business connector. To generate them simply run following job:
static void GenerateAxBC(Args _args)
{
axGenerateAxBCClass axGenerateAxBCClass;
;
axGenerateAxBCClass =
AxGenerateAxBCClass::newTableId(tablenum(WMSOrderTrans));
axGenerateAxBCClass.run();
}
You can remove the best practice error either by generating these methods OR do it from the
(Tools\DevelopmentTools\Application Integration Framework\Update document service)
The other option is to turn off this validation, if you are not using Axd
documents and AIF in your installation.
You can do that from the Best Practice Parameters (open them from
Tools\Options\Best Practices).
Simply remove the check-mark from the Application Integration Framework node
or the sub-node (this is actually what triggers this validation). It has a
description of what the check does, by the way
Comments
Post a Comment