Quantcast
Channel: Microsoft Dynamics AX Forum - Recent Threads
Viewing all articles
Browse latest Browse all 72043

Getting the batches related to a particular purchase line in a purchase order

$
0
0

Hi there,

  I have come up with the following query in order to get the batches related to purchase lines in a purchase order:

static void PurchaseBatchNumber(Args _args)
{
PurchLine purchaseLines;
InventDim inventDim;
InventBatch inventBatch;
InventSum inventSum;
Name itemName;

while select purchaseLines where purchaseLines.PurchId == "000013"
join inventDim where purchaseLines.InventDimId == inventDim.inventDimId
outer join inventBatch where inventDim.inventBatchId == inventBatch.inventBatchId
outer join inventSum where purchaseLines.ItemId == inventSum.ItemId && inventDim.inventDimId == inventSum.InventDimId
{
itemName = InventTable::find(purchaseLines.ItemId).itemName();

info(strFmt("Purchase Order: %1, Line Number: %2, Item Id: %3, Item Name: %4, Batch Number: %5, Batch Quantity Ordered: %6, Expiry date: %7, Supplier batch id: %8",
purchaseLines.PurchId, purchaseLines.LineNumber, purchaseLines.ItemId, itemName, inventBatch.inventBatchId, inventSum.Ordered, inventBatch.expDate, inventBatch.PdsVendBatchId));
}
}

And this is the result:

However, if I open the purchase order from AX and check to see the related batches for the first line, this is what I get:

I accessed this screen by going to Purchase ledger --> Purchase Orders --> All purchase orders --> Located purchase order with id 13 --> Edit --> Selected line 1 --> Inventory --> Reservation

As you can see, for the first line, there is only one entry in the infolog.  However, it appears that there are 2 batches associated with it as shown by the second screenshot.

Why is there this mismatch?  Am I doing something wrong or maybe I am not understanding something?

Thanks


Viewing all articles
Browse latest Browse all 72043

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>