Create Purchase Order via X++

void clicked()
{
    PurchTable  purchTable;
    PurchLine   purchLine;
    InventDim   inventDim;
    NumberSeq   numberSeq;

    //add by fanddy
    AxPurchTable    axPurchTable;
    AxPurchLine     axPurchLine;
    PurchFormLetter purchformLetter;
    //END

   //create PO Header
   purchTable.clear();
   purchTable.initFromVendTable(VendTable::find(TECPOGroupHeader.VendAccount));
   purchTable.DefaultDimension = InventTable::find(POGroupLine.ItemId).DefaultDimension;

   axPurchTable = axPurchTable::newPurchTable(purchTable);
   axPurchTable.parmPurchId(NumberSeq::newGetNum(PurchParameters::numRefPurchId()).num());
   axPurchTable.parmPurchaseType(PurchaseType::Purch);
   axPurchTable.parmDocumentStatus(DocumentStatus::PurchaseOrder);
   axPurchTable.parmAccountingDate(systemDateGet());
   axPurchTable.parmDeliveryDate(systemDateGet());
   axPurchTable.parmPurchStatus(PurchStatus::Backorder);
   axPurchTable.save();

   info(strFmt('Create PO %1', Purchtable.PurchId));

   //create PO Line
   purchLine.clear();
   purchLine.initValue();
   purchLine.initFromPurchTable(purchTable);
   purchLine.initFromInventTable(InventTable::find(POGroupLine2.ItemId));
   axPurchLine = AxPurchLine::newPurchLine(purchLine);
   axpurchLine.parmItemId('YOUR ITEMID');
   axPurchLine.parmPurchQty(YOUR QTY);
   axPurchLine.parmPurchPrice(YOUR PRICE);
   axPurchLine.parmInventDimId('YOUR INVENTDIMID');
   axPurchLine.save();

}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s