Calculate totals of PO using X++ in D365FO

0

Calculate totals of PO using X++ in D365FO


In Dynamics 365 FO, calculating totals of a purchase order using X++ code is given as above, copy and paste the above codes, and then,

  • Create a runnable class (job) named as CalculateTotalsOfPurchaseOrder
  • Copy the below code and paste it into the newly created class
  • Change the Purchase order id according to your system’s data
  • Execute the job

...

internal final class CalculatePurchaseOrderTotals
{
   public static void main(Args _args)
   {
       //Calculate totals per Purchase order
       PurchTotals purchTotals;
       PurchTable  purchTable  = PurchTable::find('00000041'); //Change the Purchase Order Id as per your system's data
       AmountCur   totalAmount;
       purchTotals = PurchTotals::newPurchTable(purchTable);
       purchTotals.calc();
       totalAmount = purchTotals.purchTotalAmount();
       info(strFmt("Purchase order: %1 - Total value: %2", purchTable.PurchId, totalAmount));
   } 
}

...

  • Change the purchase order number according to your system data.
  • Successfully run the project.
  • you can see the purchase order total in the info log window.

Post a Comment

0 Comments
Post a Comment
>
To Top