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");
1
Answers
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.
Concur with frish - GET ignores any filters, so the SETFILTER is a wasted statement.
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
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
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.
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!!!
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;
Yes..u r right..thank you
You can find this under the replies where you should see something like "Did this answer the question YES or NO"