ItemLedgEntry.SETCURRENTKEY("Item No.",Open,"Variant Code",Positive,"Location Code"); IF ItemLedgEntry.FINDFIRST THEN REPEAT ItemLedgEntry.SETRANGE("Item No.",ItemLedgEntry."Item No."); ItemLedgEntry.SETRANGE(Open,TRUE); ItemLedgEntry.SETRANGE("Location Code",Code); IF ItemLedgEntry.FINDLAST THEN ERROR(Text009,FIELDCAPTION("Bin Mandatory")); ItemLedgEntry.SETRANGE(Open); ItemLedgEntry.SETRANGE("Location Code"); ItemLedgEntry.FINDLAST; ItemLedgEntry.SETRANGE("Item No."); UNTIL ItemLedgEntry.NEXT = 0;
Comments
2) What you want to do? Call error if some open entry for selected location exists? For this you can just filter for any Open entry on this location and if NOT ISEMPTY than call the error...
3) If you want it for another purpose, just use temporary table where you insert e.g. the item if not already there and add second loop based on this temp table...
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
Furthermore, this code really doesn't DO anything, other than raise and error the first (or is it last? I get confused) Item for which there are ILE records in that filter. When there's a whole bunch of such Items, you will only see one error because the transaction will be aborted.
Please explain what you need to do and we'll give you some suggestions on how to approach it.
RIS Plus, LLC
Nice off you to confirm that the person who coded this doesn't know what he is doing. The good thing is that i didn't code it .
the bad news is that it is in NAVW15.00 database table 14 in the onvalidate trigger for Bin mandatory.
What do you think about that . Should we call denmark and tell them they do not know what they are doing
** SI ** Bert Van Gestel **
**********************
Yes, call them, because this is terrible code, mainly that it is not changed in SP1...
You can correct the code to something like:
But it seems that the code is written in this way because on Native DB it will not show the "Counting records" dialog... ](*,)
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
That is pretty bad code, and if it is indeed done for not showing a message in the native database server, then it should be put into a IF NOT RECORDLEVELLOCKING statement, and then put Kamil's code into the FALSE leg.
Realistically though, that code is not going to be run on any regular basis, you should really set up the locations once, at the start of the implementation.
RIS Plus, LLC
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
I constantly optimize code and indexes that I never use.
it's the client that uses it.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Dang... so many people busting my balls these days... #-o
AP Commerce, Inc. = where I work
Getting Started with Dynamics NAV 2013 Application Development = my book
Implementing Microsoft Dynamics NAV - 3rd Edition = my 2nd book
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n