CALCIFIED does not working!!

SuD
Member Posts: 102
I have two record variable of ITEM table and another one is Transferline table(Created by me).
ItemRec.SETFILTER(ItemRec."Location Filter",TransferLine."Warehouse Location");
ItemRec.GET(TransferLine."Item No");
MESSAGE('At %1 Location for Item %2',ItemRec."Location Filter",ItemRec."No.");
END;
ItemRec.CALCFIELDS("Qty. on Purch. Order");
CalcifieldVar := ItemRec."Qty. on Purch. Order";
IF CalcifieldVar >= PurchaseQuantityRequired THEN BEGIN
MESSAGE('For this Item %1 Quantity on purchase order is %2',TransferLine."Item No",ItemRec."Qty. on Purch. Order");
ItemRec.SETFILTER(ItemRec."Location Filter",TransferLine."Warehouse Location");
ItemRec.GET(TransferLine."Item No");
MESSAGE('At %1 Location for Item %2',ItemRec."Location Filter",ItemRec."No.");
END;
ItemRec.CALCFIELDS("Qty. on Purch. Order");
CalcifieldVar := ItemRec."Qty. on Purch. Order";
IF CalcifieldVar >= PurchaseQuantityRequired THEN BEGIN
MESSAGE('For this Item %1 Quantity on purchase order is %2',TransferLine."Item No",ItemRec."Qty. on Purch. Order");
1
Best Answers
-
It's likely because of this line...
UNTIL (PurchasableQuantityRecvdHre >= PurchaseQuantityRequired) AND (PurchuOrder.NEXT = 0);
...are you sure it's not supposed to be...UNTIL (PurchasableQuantityRecvdHre >= PurchaseQuantityRequired) OR (PurchuOrder.NEXT = 0);
5 -
Great, please mark this as "Answered"
You can find this under the replies where you should see something like "Did this answer the question YES or NO"5
Answers
-
So what's not working then? I think it would be good to explain what you're expecting (and why, as in: what's your business requirement?), what you're getting, and maybe what you tried to get it work.
Concerning your code: I didn't look through the whole thing, but the first are a bit weird to me.
You call an ItemRec.SETFILTER (personal preference: I'd use a SETRANGE).
Then you call ItemRec.GET, which will ignore (but not remove) all filters set.
Are you trying to calculate the qty. on purchase order for a certain location? If so -> The flowField in ItemRec will also ignore your filter.0 -
What is the output of the second MESSAGE statement?
Concur with frish - GET ignores any filters, so the SETFILTER is a wasted statement.Kyle Hardin - ArcherPoint0 -
ItemRec.SETFILTER(ItemRec."Location Filter",TransferLine."Warehouse Location");
Remove the above line. Why using setfilter if using GET???
ItemRec.GET(TransferLine."Item No"); This is enough
Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/0 -
Hei Experts,
Don't confuse SuD any more. "Location Filter" is a FlowFilter field used in calculating the "Qty. on Purch. Order" FlowField, so that code is sensible.
The order of the statements is unusual, but not wrong. I assume, code not relevant to the question has been purged.
At the first MESSAGE, I'd expect the location shown to be empty (The value is in the filter, not the field). Although, I am not entirely sure how the FlowFilter field behaves in this regard.
I assume, the END; -line is there for a good reason, and the code before it is executed, as the code excerpt suggests.
The rest of the code looks to be ok.
What is the result you get, what do you expect to get, and why.1 -
Thank you for your suggestions guyzz..But it was a problem of Infinite loop that first time i faced....:(0
-
RockWithNAV wrote: »ItemRec.SETFILTER(ItemRec."Location Filter",TransferLine."Warehouse Location");
Remove the above line. Why using setfilter if using GET???
ItemRec.GET(TransferLine."Item No"); This is enough
I want to filter items by location wise ,when i select a item from lookup table in my Transfer Line..Thats why i using setfilter after GET!!!0 -
There are no loops in the code you have posted so if the problem is an infinite loop then you need to post more code - i.e. all the code in the loop0
-
RockWithNAV wrote: »ItemRec.SETFILTER(ItemRec."Location Filter",TransferLine."Warehouse Location");
Remove the above line. Why using setfilter if using GET???
ItemRec.GET(TransferLine."Item No"); This is enough
0 -
There are no loops in the code you have posted so if the problem is an infinite loop then you need to post more code - i.e. all the code in the loop
TransferLine.SETRANGE(TransferLine."Document No.",Rec."Document No.");
IF TransferLine.FINDSET THEN REPEAT
TransferLine.CALCFIELDS(TransferLine."Quantity in Hand at WL");
PurchaseQuantityRequired := TransferLine."Quantity Required" - TransferLine."Quantity in Hand at WL";
MESSAGE('Quantity Required Final%1',PurchaseQuantityRequired);
IF TransferLine."Quantity Required" > TransferLine."Quantity in Hand at WL" THEN BEGIN
ItemRec.SETRANGE(ItemRec."No.",TransferLine."Item No");
ItemRec.SETFILTER(ItemRec."Location Filter",TransferLine."Warehouse Location");
IF ItemRec.FINDFIRST THEN
MESSAGE('At %1 Location for Item %2',ItemRec."Location Filter",ItemRec."No.");
END;
ItemRec.CALCFIELDS("Qty. on Purch. Order");
CalcifieldVar := ItemRec."Qty. on Purch. Order";
IF CalcifieldVar >= PurchaseQuantityRequired THEN BEGIN
MESSAGE('For this Item %1 Quantity on purchase order is %2',TransferLine."Item No",ItemRec."Qty. on Purch. Order");
PurchuOrder.SETRANGE(PurchuOrder."Location Code",TransferLine."Warehouse Location");
PurchasableQuantityRecvdHre := 0;
IF PurchuOrder.FINDSET THEN REPEAT
CLEAR(CodePurchaseOrder);
QuantityRcvAtPurchuLine:= 0;
PurchuLine.RESET;
PurchuLine.SETRANGE(PurchuLine."Document No.",PurchuOrder."No.");
PurchuLine.SETRANGE(PurchuLine."No.",TransferLine."Item No");
IF PurchuLine.FINDFIRST AND ((PurchuLine.Quantity - PurchuLine."Quantity Received")<>0) THEN BEGIN
PurchasableQuantityRecvdHre := PurchasableQuantityRecvdHre + PurchuLine.Quantity - PurchuLine."Quantity Received";
QuantityRcvAtPurchuLine := PurchuLine.Quantity - PurchuLine."Quantity Received";
PurchuLine.VALIDATE(PurchuLine."Qty. to Receive",QuantityRcvAtPurchuLine);
PurchuLine.MODIFY;
PurchuOrder.Receive := TRUE;
PurchuOrder.Invoice := FALSE;
PurchuOrder.MODIFY;
CodePurchaseOrder.RUN(PurchuOrder);
MESSAGE('%1%2',PurchasableQuantityRecvdHre,PurchaseQuantityRequired)
END;
UNTIL (PurchasableQuantityRecvdHre >= PurchaseQuantityRequired) AND (PurchuOrder.NEXT = 0);
END;
UNTIL TransferLine.NEXT = 0;0 -
It's likely because of this line...
UNTIL (PurchasableQuantityRecvdHre >= PurchaseQuantityRequired) AND (PurchuOrder.NEXT = 0);
...are you sure it's not supposed to be...UNTIL (PurchasableQuantityRecvdHre >= PurchaseQuantityRequired) OR (PurchuOrder.NEXT = 0);
5 -
It's likely because of this line...
UNTIL (PurchasableQuantityRecvdHre >= PurchaseQuantityRequired) AND (PurchuOrder.NEXT = 0);
...are you sure it's not supposed to be...UNTIL (PurchasableQuantityRecvdHre >= PurchaseQuantityRequired) OR (PurchuOrder.NEXT = 0);
Yes..u r right..thank you0 -
Reading the code again, I'm 100% certain that it should be an OR instead of an AND - change it and it will fix your infinite loop problem1
-
Great, please mark this as "Answered"
You can find this under the replies where you should see something like "Did this answer the question YES or NO"5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions