Calculate planning filter not working

MisConsultng
Member Posts: 17
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
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
Best Answers
-
Try with the CLEAR function instead of RESET like
CLEAR(ReqLine);
May be somewhere it is trying to insert. It would be great if you post the complete code?
Thanks.
Best Regards
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.5 -
It's your filter on "Journal Batch Name" - remove it if you want to check if the sales order appears on any worksheet. If you only want to check if it appears on the current worksheet then change it to...
ReqLine.SETRANGE("Journal Batch Name",Rec."Journal Batch Name");
...and you also filter on the Journal Template Name in this case5
Answers
-
Try with the CLEAR function instead of RESET like
CLEAR(ReqLine);
May be somewhere it is trying to insert. It would be great if you post the complete code?
Thanks.
Best Regards
Zohaib Ahmed
Dynamics NAV ERP Technical Consultant.
please like / agree / verify my answer, if it was helpful for you. thanks.5 -
It's your filter on "Journal Batch Name" - remove it if you want to check if the sales order appears on any worksheet. If you only want to check if it appears on the current worksheet then change it to...
ReqLine.SETRANGE("Journal Batch Name",Rec."Journal Batch Name");
...and you also filter on the Journal Template Name in this case5
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