Hello, I must realise a comparison of amounts and I do not know very clearly like doing it; I suppose that more than nothing it's a formula concept.
I 've created a table with the fields "Client", "Product" and "Amount to reserve" and what I want is that when realising a sale order, before registering, if the client of the order is not the same from the table that I've created, let's register but don't if the product is reserved for another client.
I've got it more or less. But now I want that if there are Inventory it allows to register the order although is not for the indicated client.
I put an example:
Amount to reserve: 200
Inventory: 100
Requested amount in sale line: 50
In this case it would not have to let register because the amount of the order and Inventory they give 150 and I have reserved 200 for another client at the moment.
On the following example would have to leave:
Reserved amount: 200
Inventory: 500
Requested amount in sale line: 250
Because they would continue being 250 and I only need to reserve 200. I'll like to know the formulate or expression (translated to c/AL) have I to use to do this comparison.
Thank you very much.
0
Comments
Anyhow, I would create a function in the "Sales Line" table, let's say CheckReservation.
In this function, supposing your new created table is referenced as MyTable, and is having one of the keys: Client,Product, I would write the following code:
For me it seems like standard calculation of Item availability which will display you the Inventory warning.
All is done on the Warning Form (Form 342) - See function "Calculate".
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I've tried your code but it seems don't work well, but I it's fault from mine; I've forgotten to comment that when the customer it's the same from my reserve table it let's to register. Also, in my reserve table, I have the option field Reserve, marking it would have to allow all the explained one, but not if it is not marked. How could to include this two conditions in the code?.
Many thanks for help.
Thanks.
Sorry, I forgotten something very important #-o:
Thank you very much.
Thanks in advance.
So, let's consider the following scenario. We have the Item No. 123, Inventory = 15 pcs, Reserved Qty. = 2 pcs. We have this Item with the Quantity (Base) = 10 pcs. on the second line of the Sales Order. The CheckReservation function will find that 10 < 15 - 2, therefore you can go further. On the sixth line of our Sales Order, we have again the Item 123, with a Quantity (Base) of 6. The CheckReservation function will again check the availability of these 6 pieces, and will find that everything is ok, because 6 < 15 -2. So, in total, we will be allowed to register (BTW, register = post?) 10 pcs. + 6 pcs. = 16 pcs., which is more than we have in the Inventory, and even more than we have available not reserved.
Is this correct?
Product Quantity Inventory Reserved
001 20 50 10
002 30 20 10
Imgine that the reserved product it's the product 002 and my code line from error message says:
"ERROR('You cannot register more than %1', Item.Inventory - ReservedQty);"
On register it's stop because find a reserved line, but the message says:
ERROR: "You cannot register more than 40"
And it would have of being "You cannot register more than 10", because is the product 002. The problem is the message, no the function.
Sorry if I don't explain well.
Thanks.