Getting the First Date of a Shortage

CarolynSasser
Member Posts: 2
Hi I am new to Nav.
I need to run a report that shows me what date and SO we will be short for an Item.
example for the item listed below I need to get the date 11/21/2018 and the SO SO100306.
Item No Date SO QTY Inv after Order
F100314S 10/26/2018 SO100296 420 628
11/16/2018 SO100307 420 208
11/21/2018 SO100306 420 -212
11/23/2018 SO100308 420 -632
Can anyone give me some advise?
Thank you
I need to run a report that shows me what date and SO we will be short for an Item.
example for the item listed below I need to get the date 11/21/2018 and the SO SO100306.
Item No Date SO QTY Inv after Order
F100314S 10/26/2018 SO100296 420 628
11/16/2018 SO100307 420 208
11/21/2018 SO100306 420 -212
11/23/2018 SO100308 420 -632
Can anyone give me some advise?
Thank you
0
Best Answer
-
In my opinion, create a report then define Item table to be data source. then recursive into sales order line to find the first date of shortage.
I just show you an example code for guiding (it need to be refined a little bit if you want more complete result).Item - OnAfterGetRecord() CALCFIELDS(Inventory); CLEAR(ShortageDate); ShortageQty := Inventory; SalesLine.RESET; SalesLine.SETCURRENTKEY("Posting Date"); SalesLine.SETRANGE("Document Type",SalesLine."Document Type"::Order SalesLine.SETRANGE(Type,SalesLine.Type::Item); SalesLine.SETRANGE("No.",Item."No."); IF SalesLine.FIND('-') THEN REPEAT SalesLine.CALCFIELDS("Posting Date"); ShortageQty := ShortageQty - SalesLine."Outstanding Qty. (Base)"; IF ShortageQty < 0 THEN BEGIN ShortageDate := SalesLine."Posting Date"; SO := SalesLine."Document No."; END; UNTIL (SalesLine.NEXT = 0) OR (ShortageQty < 0);
5
Answers
-
In my opinion, create a report then define Item table to be data source. then recursive into sales order line to find the first date of shortage.
I just show you an example code for guiding (it need to be refined a little bit if you want more complete result).Item - OnAfterGetRecord() CALCFIELDS(Inventory); CLEAR(ShortageDate); ShortageQty := Inventory; SalesLine.RESET; SalesLine.SETCURRENTKEY("Posting Date"); SalesLine.SETRANGE("Document Type",SalesLine."Document Type"::Order SalesLine.SETRANGE(Type,SalesLine.Type::Item); SalesLine.SETRANGE("No.",Item."No."); IF SalesLine.FIND('-') THEN REPEAT SalesLine.CALCFIELDS("Posting Date"); ShortageQty := ShortageQty - SalesLine."Outstanding Qty. (Base)"; IF ShortageQty < 0 THEN BEGIN ShortageDate := SalesLine."Posting Date"; SO := SalesLine."Document No."; END; UNTIL (SalesLine.NEXT = 0) OR (ShortageQty < 0);
5 -
Thank you for the help. I actually had to place it on Sales Lines - OnAfterGetRecord() as It wasn't assosiating with the correct item. I also has to add a sort on the Shipment Date as I needed to know what shipment date the item was going to be short.
That being said, you code was great in solving the problem.0
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