How to post SO's or PO's with X++
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;
}
6 comments:
Thank you wery mutch
Andrus@Estonia
Hi,
Very useful post.But for one change,
salesTable.DocumentStatus == DocumentStatus::Invoice has to be
salesTable.DocumentStatus < (or !=) DocumentStatus::Invoice
Regards,
Venkatesh
Hi,
I was searching for something similar, thanks a lot for posting this, you really made my day. :)
Rgds,
Praveen
Hello,
Do you have the code to unpost a po?
I have been playing with the same class to try to reverse the posting by updating the recieved now qty and calling the same update method but I dont get the desire results, any help will be very much appreciated.
Thanks.
Hi !!
thanks a lot Mr Basu.. ur blogs have been very usefull always....
I have a small doubt while doing the same PO invoice the purchFormLetter.update(), asks for a 'num'. Can u pla tel me... what is this num??
Thanking you in advance.
Debashree Dutta
Hi!!
Thanks for the detailed prpgram, ur blogs hav always been very useful.
Can u plz tell me while doing the same for PO, the purchFormLetter.update() method asks for a 'num' type argument. Can u pla tell me what is this??
Thanking u in advance.
Debashree
Post a Comment