Create Purchase order or Sales order and invoice through X++


static void CreatePOAndInvoice(Args _args)

{
     PurchTable      purchTable;
     PurchLine       purchLine;
     VendTable       vendTable = VendTable::find("1000");
     AxPurchTable    axPurchTable;
     AxPurchLine     axPurchLine;
     PurchFormLetter purchFormLetter;
     ;

    //Create Purchase order
     purchTable.initFromVendTable(vendTable);

     axPurchTable = axPurchTable::newPurchTable(purchTable);
     axPurchTable.parmPurchaseType(PurchaseType::Purch);
     axPurchTable.parmDocumentStatus(DocumentStatus::PurchaseOrder);
    // axPurchTable.parmAccountingDate(systemDateGet());
     axPurchTable.parmDeliveryDate(01\06\2012);
     axPurchTable.parmPurchStatus(PurchStatus::Backorder);
     axPurchTable.doSave();

    //Create PurchLine for item 1000
     purchLine.initFromPurchTable(purchTable);

    axPurchLine = AxPurchLine::newPurchLine(purchLine);
     axpurchLine.parmItemId("Test29");
     axpurchLine.parmInventDimId('00000063_069');
     axPurchLine.parmPurchQty(10);
     axPurchLine.parmPurchPrice(100);
     axPurchLine.doSave();

    //Posting PO Confirmation,I guess its mandatory
    //You cannot do invoice without doing PO confirm
    purchTable = axPurchTable.purchTable();
     purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
     purchFormLetter.update(purchTable, strFmt("Inv_%1", purchTable.PurchId));

    //Posting PO Invoice
     purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);
     purchFormLetter.update(purchTable, strFmt("Inv_%1", purchTable.PurchId));

}

6 comments:

  1. thanks for post,
    I am new ax technology and i am to learn ax2012 and this blog help to me increase my knowledge..

    ReplyDelete
  2. Hi Amir,
    Good to see you here!!
    You can go through the blog to help enhance your technical skills in AX.
    If anyone have any doubts, can also post that.

    ReplyDelete
  3. Hi Vishal
    Can u please give me you mail Id and Contact Number.

    ReplyDelete
  4. http://shrishailtechnologies.wordpress.com/2012/04/27/ax-2012-x-code-to-create-and-post-purchase-order-invoice/

    ReplyDelete
  5. This code will not invoice because it needs document date for posting, only pending invoice will be created

    ReplyDelete
  6. Interesting stuff guys. Now almost in all the countries of world prefer to buy products online to save time as well as the money. I also prefer digital portals for saving time instead of visiting the market. This information will be the basis for comparison. As an object of benchmarking, you need to choose areas of guts(.)pk/ where the indicators significantly lag behind the standard. Thanks for it

    ReplyDelete

Powered by Blogger.