Creating a purchase order
Purchase orders are used throughout the purchasing process to hold the information about the goods or services that a company buys from its suppliers. Normally, purchase orders are created from the user interface, but in automated processes, purchase orders can be also created from code.
In this recipe, we will learn how to create a purchase order from code. We will use a standard method provided by the application.
How to do it...
1. In the AOT, create a new job named
PurchOrderCreate
with the following code:static void PurchOrderCreate(Args _args) { NumberSeq numberSeq; PurchTable purchTable; PurchLine purchLine; ttsBegin; numberSeq = NumberSeq::newGetNum( PurchParameters::numRefPurchId()); numberSeq.used(); purchTable.PurchId = numberSeq.num(); purchTable.initValue(); purchTable.initFromVendTable(VendTable::find('1001')); if (!purchTable.validateWrite()) { throw Exception::Error; } purchTable.insert(); purchLine.PurchId = purchTable.PurchId; purchLine.ItemId ...