Hi all,
I am struggling with what appears to be simple but I somehow can't get past the error. Basically I want to calculate demand based on sales orders and if the planning worksheet already contains the SOs then skip it, else mark it for later processing. I have the following code to check for this condition:
ReqLine.RESET;
ReqLine.SETCURRENTKEY("Journal Batch Name","Sales Order No.","Sales Order Line No.");
ReqLine.SETRANGE("Journal Batch Name",ReqLine."Journal Batch Name");
ReqLine.SETFILTER("Sales Order No.",'%1',SHeaderOrderDate."No.");
ReqLine.SETFILTER("Sales Order Line No.",'%1', SLine."Line No.");
IF NOT (ReqLine.FINDFIRST) THEN
SLine.MARK(TRUE);
No matter what the error keeps on coming up stating that Line # so and so already exists. Yes, duh, I knew that. But my code is saying if not found then mark it. Why do I get an error on the IF NOT (ReqLine.FINDFIRST) THEN statement? Can someone please explain to me?
I also tried the opposite direction, whereas my filters would be '<>%1' then IF (ReqLine.FINDFIRST) THEN and either way I get the same exact error. Appreciate your guidance.
MisConsultng
0
Answers
CLEAR(ReqLine);
May be somewhere it is trying to insert. It would be great if you post the complete code?
Thanks.
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.
...and you also filter on the Journal Template Name in this case