If you need to update a sales order or a purchase order without any user dialogs, Axapta provides you with a simple interface to do just that.The SalesFormLetter and PurchFormLetter classes contain the update method, which gives you an easy interface to setup and run posting of a sales order or a purchase order.
static void postSalesFormLetter(Args _args)
{
SalesFormLetter salesFormLetter;
salesTable salesTable;
ttsBegin;
while select salesTable
where salesTable.DocumentStatus == DocumentStatus::Invoice &&
salesTable.SalesId == 'SO/07/123' // Select the SO Number
{
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); // Get a new instance of SalesFormletter
salesFormLetter.transDate(SystemDateGet()); // Set the invoicedate
salesFormLetter.update(salesTable, // SalesTable
SalesUpdate::All, // Quantity to update (SpecQty)
AccountOrder::None, // AccountOrder
false, // Proforma only?
true); // Printout?
}
ttsCommit;
}