Good Afternoon everyone, I have a report that needs to access Item Ledger Entry table the Entry Type field. I would like to pull through the Purchase Invoiced Quantity and Sales Invoiced Quantity and have it print on the report. I have tried using a setrange. I have written it this way. CLEAR(InvQty); ItemledgerEntry.SETRANGE(“Item No.”, “No.”); ItemledgerEntry.SETRANGE(“Entry Type”,‘Purchase’); If ItemledgerEntry.FIND(’+’) then InvQty[1] := ItemledgerEntry.“Invoiced Quantity”; ItemledgerEntry.SETRANGE(“Entry Type”,‘Sale’); If ItemledgerEntry.FIND(’+’) then InvQty[2] := ItemledgerEntry.“Invoice Quantity”; The error I get when I try to compile the report is "Type conversion is not possible because 1 of the operators contains an invalid type. Option := Text. I know that Entry Type is a field type Option. But what is the type Purchase or should I use ‘P’. Can this be done or should I go back to the drawing board and try another way to get the purchased invoiced quantity? THanks for any help SBANATT
Hi
quote:
Originally posted by Sbanatt
… ItemledgerEntry.SETRANGE(“Entry Type”,‘Purchase’); …
If you want to filter on a option field in Navision you should use integers instead of the text. The first option is = 0, the second = 1 and so on … In your example: ... ItemledgerEntry.SETRANGE("Entry Type",0); **0 = Purchase** ... ItemledgerEntry.SETRANGE("Entry Type",1); **1 = Sale** ...
bye André
Hi Andre! Instead of using hardcoded integers which will result in strange and hard to find errors upon changes of the underlying field definition, “Entry Type”::Purchase is more recommendable [;)]
You don’t need to write ’ before and after Option value: ... ItemledgerEntry.SETRANGE("Entry Type",Purchase); ... ItemledgerEntry.SETRANGE("Entry Type",Sale); ...
In fact… unless you’re on the itemledgerentry dataitem you can use something like this (Arthur’s code will give you an error as is not correct just to put purchase or sale): ItemLedgerEntry.SETRANGE(“Entry type”,ItemLedgerEntry.“Entry type”::“Purchase”); ItemLedgerEntry.SETRANGE(“Entry type”,ItemLedgerEntry.“Entry type”::“Sale”); Regards
Yeah, right [|)] Sorry for wrong code folks … no time to test [:(] But idea was right one [^]
hey why the Oldies are making ERRORS [:D] Harikesh
quote:
Originally posted by yharikesh
hey why the Oldies are making ERRORS [:D] Harikesh
Who are the Oldies??? I’m just 28… [:D]… and what errors?? I see no errors… only improvements or undocumented features on these posts… [:D][:D]
[:D][:D] I have to agree with Alfonso. I’m younger than he and I can afford to invent some new features [:D]
quote:
Originally posted by yharikesh
hey why the Oldies are making ERRORS [:D] Harikesh
Perhaps do you mean the amount of stars? [8D][8D] Nobody is perfect. AND I guess almost everybody is here to learn more [;)]. PS Should we open a new poll: What is the better way to filter OptionFields? [:D] bye André
Yes please open a new poll ( what is a poll) to find a better way to filter OptionFields. You are all young to me!
No poll is needed … this subject was discussed some time ago in Break Space. Poll is poll [:D] there you can vote for your favorite answer [:)]
Ok How about this is there a place to look to see other questions and answers for using filters on OptionFields. Because I am not getting any printed results when I use the Item Table only. I am now trying to use the Item Ledger Entry table. But another problem has occured I need to add a required (for our company) field to the Field Menu. Is this hard to do?
Here it is: http://www.navision.net/forum/topic.asp?TOPIC_ID=6307 Didn’t his help you?: ItemLedgerEntry.SETRANGE("Entry type",ItemLedgerEntry."Entry type"::Purchase); ItemLedgerEntry.SETRANGE("Entry type",ItemLedgerEntry."Entry type"::Sale);
Sorry Arthur but no.
quote:
Originally posted by Sbanatt
Sorry Arthur but no.
Ok, Banatt… I think that here we’re having two different problems… one is how to set a filter in an option field (that’s solved in the previous posts), and the other one is your code on that report… that’s the probably cause of not getting any result… going back to your first post, here’s your code: CLEAR(InvQty); ItemledgerEntry.SETRANGE("Item No.", "No."); ItemledgerEntry.SETRANGE("Entry Type",'Purchase'); If ItemledgerEntry.FIND('+') then InvQty[1] := ItemledgerEntry."Invoiced Quantity"; ItemledgerEntry.SETRANGE("Entry Type",'Sale'); If ItemledgerEntry.FIND('+') then InvQty[2] := ItemledgerEntry."Invoice Quantity";
On your code you’re just getting the last item ledger entry for sales and for purchases (that can have invoiced quantity = 0). If you’re wanting to get the sum of all the quantities invoiced for those two types of sales… change your code to be as follows: CLEAR(InvQty); ItemLedgerEntry.RESET; ItemLedgerEntry.SETCURRENTKEY("Entry type","Item No."); ItemLedgerEntry.SETRANGE("Entry Type","Entry type"::"Purchase"); ItemLedgerEntry.SETRANGE("Item No.", "No."); ItemLedgerEntry.CALCSUMS("Invoiced Quantity"); // the standard version has a couple keys starting by // Entry type, Item No. where Invoiced quantity is a sumindex InvQty[1] := ItemLedgerEntry."Invoiced Quantity"; ItemLedgerEntry.SETRANGE("Entry type","Entry type"::"Sale"); ItemLedgerEntry.CALCSUMS("Invoiced Quantity"); InvQty[2] := ItemLedgerEntry."Invoiced Quantity";
Just tell me if it works for you so i can send you my bill…[}:)][:D][:D] Regards,
Hi Alfonso, does your code really work? Because after setting the range of ItemLedgerEntry to Purchase, starting the next Setrange to Sales will not lead to any result, because Navision looks first to find data with entrytype Purchase and then within this range data with entrytype Sales. Am I right or starts Navision a 'Re-'range? Michael
Well… you can always try it in a test database if you don’t trust me… [;)] It works, i promise. On the first setrange we’re filtering the records where Entry type is Purchase, but when you set the second setrange it’s not keeping the first one, but replacing the previous filter. Maybe you can understand it better if showing this as example: itemledgerentry.SETRANGE(“Entry type”,itemledgerentry.“Entry type”::“Sale”); ItemledgerEntry.SETRANGE(“Entry type”); If it were keeping the filters, the second line should have no sense, but if you try this you’ll find that what’s doing is setting a filter and the second line is removing the first filter. In the a lot of ocassions is a useful feature, as you’re not needing to rewrite the previous filters… sometimes it’s not, and that’s when mark becomes more useful… Regards,
Dear Michael, That piece of code was only example. If you look to first post in this topic you’ll see what this code is used for [;)]
Hi Alfonso, for me, this is new, that Navision is just replacing the first filter. And does this mean, that I don’t have to do the range to Item No. again? Michael