How do you debug this?
ara3n
Member Posts: 9,258
Why would you write code like this and how do you debug this?
IF CalculatedCorrectly2 AND
((RFStatEntryTotal2."Outstanding Quantity" <> 0) OR
RFEmployeeSetup."Ignore Action Outst. Qty of 0") AND
((RFStatEntryTotal2."Available Volume" >=
OutboundWhseRequestFilter."Minimum Avail. Volume") AND
((RFStatEntryTotal2."Available Volume" <=
OutboundWhseRequestFilter."Maximum Avail. Volume") OR
(OutboundWhseRequestFilter."Maximum Avail. Volume" = 0))) AND
((RFStatEntryTotal2."Available Gross Weight" >=
OutboundWhseRequestFilter."Minimum Avail. Gross Weight") AND
((RFStatEntryTotal2."Available Gross Weight" <=
OutboundWhseRequestFilter."Minimum Avail. Gross Weight") OR
(OutboundWhseRequestFilter."Maximum Avail. Gross Weight" = 0))) AND
((RFStatEntryTotal2."Net Weight (Base)" >=
OutboundWhseRequestFilter."Minimum Avail. Net Weight") AND
((RFStatEntryTotal2."Net Weight (Base)" <=
OutboundWhseRequestFilter."Maximum Avail. Net Weight") OR
(OutboundWhseRequestFilter."Maximum Avail. Net Weight" = 0))) AND
((RFStatEntryTotal2."Available Qty. (Base)" >=
OutboundWhseRequestFilter."Minimum Avail. Qty. (Base)") AND
((RFStatEntryTotal2."Available Qty. (Base)" <=
OutboundWhseRequestFilter."Maximum Avail. Qty. (Base)") OR
(OutboundWhseRequestFilter."Maximum Avail. Qty. (Base)" = 0))) AND
((RFStatEntryTotal2."Available Amount" >=
OutboundWhseRequestFilter."Minimum Avail. Amount") AND
((RFStatEntryTotal2."Available Amount" <=
OutboundWhseRequestFilter."Maximum Avail. Amount") OR
(OutboundWhseRequestFilter."Maximum Avail. Amount" = 0))) AND
((RFStatEntryTotal2."Outstanding No. of Lines" >=
OutboundWhseRequestFilter."Minimum Outst. No. of Lines") AND
((RFStatEntryTotal2."Outstanding No. of Lines" <=
OutboundWhseRequestFilter."Maximum Outst. No. of Lines") OR
(OutboundWhseRequestFilter."Maximum Outst. No. of Lines" = 0))) AND
(((ValueType = 0) AND (RFStatEntryTotal2."Outstanding Quantity" <> 0)) OR
((ValueType = 1) AND (RFStatEntryTotal2."Available Quantity" <> 0)) OR
((ValueType = 2) AND (RFStatEntryTotal2."Total Available Quantity" <> 0)) OR
((ValueType = 3) AND
(RFStatEntryTotal2."Outstanding Quantity" = RFStatEntryTotal2."Available Quantity")) OR
((ValueType = 4) AND
(RFStatEntryTotal2."Total Available Quantity" > RFStatEntryTotal2."Available Quantity"))) OR
((ValueType = 5) AND (RFStatEntryTotal2."Inv. Reserved Quantity" <> 0)) OR
((ValueType = 6) AND
(RFStatEntryTotal2."Outstanding Quantity" <> 0) AND
(RFStatEntryTotal2.Quantity = RFStatEntryTotal2."Outstanding Quantity")) OR
((ValueType = 7) AND
(RFStatEntryTotal2."Outstanding Quantity" <> 0) AND
(WarehouseRequestTmp."Shipment Date" < WORKDATE)) OR
((ValueType = 8) AND
(RFStatEntryTotal2."ATO Quantity" <> 0)) OR
((ValueType = 10) AND
(RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND
(RFStatEntryTotal2."Outstanding Quantity" <> 0)) OR
((ValueType = 11) AND
(RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND
(RFStatEntryTotal2."Available Quantity" <> 0)) OR
((ValueType = 12) AND
(RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND
(RFStatEntryTotal2."Total Available Quantity" <> 0)) OR
((ValueType = 13) AND
(RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND
(RFStatEntryTotal2."Outstanding Quantity" = RFStatEntryTotal2."Available Quantity")) OR
((ValueType = 14) AND
(RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND
(RFStatEntryTotal2."Total Available Quantity" > RFStatEntryTotal2."Available Quantity")) OR
((ValueType = 15) AND
(RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND
(RFStatEntryTotal2."Inv. Reserved Quantity" <> 0)) OR
((ValueType = 16) AND
(RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND
(RFStatEntryTotal2."Outstanding Quantity" <> 0) AND
(RFStatEntryTotal2.Quantity = RFStatEntryTotal2."Outstanding Quantity")) OR
((ValueType = 17) AND
(RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND
(RFStatEntryTotal2."Outstanding Quantity" <> 0) AND
(WarehouseRequestTmp."Shipment Date" < WORKDATE)) OR
((ValueType = 18) AND
(RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND
(RFStatEntryTotal2."ATO Quantity" <> 0))
THEN BEGIN
0
Answers
-
Crazy!!0
-
I'd debug this writing all separate boolean outcomes to a textfile or message0
-
Is this AI programmed in NAV?
0 -
Without completely refactoring this Brainf*ck
Remove the third closing bracket the following line(RFStatEntryTotal2."Total Available Quantity" > RFStatEntryTotal2."Available Quantity"))) OR
like this(RFStatEntryTotal2."Total Available Quantity" > RFStatEntryTotal2."Available Quantity")) OR
and add a third closing bracket the last line(RFStatEntryTotal2."ATO Quantity" <> 0))
like this(RFStatEntryTotal2."ATO Quantity" <> 0)))
0 -
Noticed there might not be a ValueType 9
OnRun() IF CalculatedCorrectly2 AND CheckOutstandingQuantity AND CheckAvailableVolume AND CheckAvailableGrossWeight AND CheckNetWeight AND CheckAvailableQty AND CheckAvailableAmount AND CheckOutstandingNoOfLines AND CheckValueType THEN BEGIN END; LOCAL CheckOutstandingQuantity() : Boolean EXIT( (RFStatEntryTotal2."Outstanding Quantity" <> 0) OR RFEmployeeSetup."Ignore Action Outst. Qty of 0" ); LOCAL CheckAvailableVolume() : Boolean EXIT(IsBetweenMinMax(RFStatEntryTotal2."Available Volume", OutboundWhseRequestFilter."Minimum Avail. Volume", OutboundWhseRequestFilter."Maximum Avail. Volume")); LOCAL CheckAvailableGrossWeight() : Boolean EXIT(IsBetweenMinMax(RFStatEntryTotal2."Available Gross Weight", OutboundWhseRequestFilter."Minimum Avail. Gross Weight", OutboundWhseRequestFilter."Maximum Avail. Gross Weight")); LOCAL CheckNetWeight() : Boolean EXIT(IsBetweenMinMax(RFStatEntryTotal2."Net Weight (Base)", OutboundWhseRequestFilter."Minimum Avail. Net Weight", OutboundWhseRequestFilter."Maximum Avail. Net Weight")); LOCAL CheckAvailableQty() EXIT(IsBetweenMinMax(RFStatEntryTotal2."Available Qty. (Base)", OutboundWhseRequestFilter."Minimum Avail. Qty. (Base)", OutboundWhseRequestFilter."Maximum Avail. Qty. (Base)")); LOCAL CheckAvailableAmount() : Boolean EXIT(IsBetweenMinMax(RFStatEntryTotal2."Available Amount", OutboundWhseRequestFilter."Minimum Avail. Amount", OutboundWhseRequestFilter."Maximum Avail. Amount")); LOCAL CheckOutstandingNoOfLines() : Boolean EXIT(IsBetweenMinMax(RFStatEntryTotal2."Outstanding No. of Lines", OutboundWhseRequestFilter."Minimum Outst. No. of Lines", OutboundWhseRequestFilter."Maximum Outst. No. of Lines")); LOCAL CheckValueType() : Boolean CASE ValueType OF 0: EXIT(RFStatEntryTotal2."Outstanding Quantity" <> 0); 1: EXIT(RFStatEntryTotal2."Available Quantity" <> 0); 2: EXIT(RFStatEntryTotal2."Total Available Quantity" <> 0); 3: EXIT(RFStatEntryTotal2."Outstanding Quantity" = RFStatEntryTotal2."Available Quantity"); 4: EXIT(RFStatEntryTotal2."Total Available Quantity" > RFStatEntryTotal2."Available Quantity"); 5: EXIT(RFStatEntryTotal2."Inv. Reserved Quantity" <> 0); 6: EXIT( (RFStatEntryTotal2."Outstanding Quantity" <> 0) AND (RFStatEntryTotal2.Quantity = RFStatEntryTotal2."Outstanding Quantity") ); 7: EXIT( (RFStatEntryTotal2."Outstanding Quantity" <> 0) AND (WarehouseRequestTmp."Shipment Date" < WORKDATE) ); 8: EXIT(RFStatEntryTotal2."ATO Quantity" <> 0); 10: EXIT( (RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND (RFStatEntryTotal2."Outstanding Quantity" <> 0) ); 11: EXIT( (RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND (RFStatEntryTotal2."Available Quantity" <> 0) ); 12: EXIT( (RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND (RFStatEntryTotal2."Total Available Quantity" <> 0) ); 13: EXIT( (RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND (RFStatEntryTotal2."Outstanding Quantity" = RFStatEntryTotal2."Available Quantity") ); 14: EXIT( (RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND (RFStatEntryTotal2."Total Available Quantity" > RFStatEntryTotal2."Available Quantity") ); 15: EXIT( (RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND (RFStatEntryTotal2."Inv. Reserved Quantity" <> 0) ); 16: EXIT( (RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND (RFStatEntryTotal2."Outstanding Quantity" <> 0) AND (RFStatEntryTotal2.Quantity = RFStatEntryTotal2."Outstanding Quantity") ); 17: EXIT( (RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND (RFStatEntryTotal2."Outstanding Quantity" <> 0) AND (WarehouseRequestTmp."Shipment Date" < WORKDATE) ); 18: EXIT( (RFStatEntryTotal2."Outstanding No. of Lines" = 1) AND (RFStatEntryTotal2."ATO Quantity" <> 0) ); END; LOCAL IsBetweenMinMax(CheckValue : Decimal;MinimumValue : Decimal;MaximumValue : Decimal) : Boolean EXIT( (CheckValue >= MinimumValue) AND ( (CheckValue <= MaximumValue) OR (MaximumValue = 0) ));0 -
Thanks. I posted this as an example of how not to code. And this part of Eship Lanham ACE warehousing solution code.0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions


