Thursday, 20 February 2014

AX2012 R2 CU7: X++ code to post Product Receipt for a Purchase Order

Hi Friends,
The below can be used to post the product receipt for a purchase order. It is same as we used to do in previous version but it is good to keep it handy.

The main thing is to pass the parameters in update method. The below job will post the product receipt for the inventory quantities which have been Registered. Please note the purchase order should be confirmed before posting the product receipt.


To reuse it quickly, here it is:


static void Job12(Args _args)
{
    PurchTable  purchTable = PurchTable::find("000032");
    PurchFormLetter     purchFormLetter;
   
    purchFormLetter = purchFormLetter::construct(DocumentStatus::PackingSlip);
    purchFormLetter.update( purchTable,
                            "PA009",
                            systemDateGet(),
                            PurchUpdate::RegisteredAndServices,
                            AccountOrder::None,
                            false,
                            false);
   
    info("Done");
   
}



 

2 comments:

  1. Hy Priyanka,

    I got this error when run the code:

    "Cannot create a record in Purchase order - update table (PurchParmTable). Purchase order: xxxxxxxxxxx. The record already exists.

    The purchase order mentioned in the info error message isn't the order I try to receipt.

    Run this code in ax 2012 R2 CU6
    Any idea ?

    Bye.
    Dante.

    ReplyDelete
  2. I Solve, deleting some records in error in the table "PurchParmTable".

    ReplyDelete