From: http://blog.ak-home.net/CategoryView,category,Dynamics%2BAx%2cProgrammierung%2cAPI.aspx
An order in Microsoft Dynamics AX is a record in the table "SalesTable"(order header), if the contract contains an articel, a record exists in table "SalesLine". In addition, depending on the data of the contract (e.g. One time customer: Yes/No, inter company: Yes/no, etc.) additional records will exist in other tables.
The logic of creation of individual records of the various tables is displayed in Microsoft Dynamics AX through classes "SalesTableType", "SalesLineType" and their derived classes. These classes control the behavior of creating, modifing and deletion of a job.
These classes are called from overridden methods of the tables "SalesTable" and "SalesLine". For example, method "Insert" of table "SalesTable" which call the "SalesTableType". Depending on the type of the order, specified object is created ("SalesTableType_Sales", "SalesTableType_ItemReq", etc.).
Other methods like "update", "delete", "initValue", "validateField" are overwrote in the same way.
It will be clear if you look into methods of table "SalesTable" and "SalesLine".
Thus, creating a new order is quite easy because the entire business logic behind an order is automatically callled.
To create a new order:
1. A new reference number of the number sequence can be drawn.
2. The method "initValue" of table "SalesOrder" must be called
3. The customer must be assigned.
4. The method "initFromCustAccount" of table “SalesTable" must be called.
5. The method "insert" of table "SalesTable" must be called.
To create sales line, just call method "CreateLine" of table "SalesLine" with the prior definition of the order number("SalesLine.SalesId") and article("SalesLine.ItemId").
For example: