How to grouping by item category code in C/AL

undy0602
Member Posts: 67
Hello all,
I have sum Amount Including Vat of Sales Line grouping by Item Category Code in C/AL. How to group it?
I have sum Amount Including Vat of Sales Line grouping by Item Category Code in C/AL. How to group it?
0
Best Answer
-
Try something like this...
Salesline.reset Salesline.setfilter("document no", "No.") If salesline.findset then repeat TempSales.reset TempSales.setrange("item category code", salesline."item category code") If TempSales.findfirst then begin TempSales."amount including vat" += Salesline."amount including vat"; TempSales.modify; End Else begin TempSales:=SalesLine TempSales.insert; End; Until SalesLine.next=0
1
Answers
-
Hi @undy0602 ,
Where you want to group it - In report , page or during a custom code?
Thanks & Regards,
Saurav Dhyani
Do you Know this About NAV?
Connect - Twitter | Facebook | Google + | YouTube
Follow - Blog | Facebook Page | Google + Page0 -
Hi @postsaurav,
I want it to group in page and codeunit0 -
For codeunit...
1) create temp record for sales line
2) loop through sales lines you want to group on
3) check if temp sales line exists with same item category code as current sales line
4) if no then add current sales line to temp sales line
5) if yes then add amount incl vat to temp sales line
6) repeat above for each sales line
Now you have a set of temp sales lines - 1 per item category code,
For page, it depends what you need, you could do something similar to the above and then have a page running the temp sale line0 -
Thanks @Kishorm,
I tried it on below code
Salesline.reset
Salesline.setfilter("doc no", "No.")
If salesline.findset then repeat
TempSales.reset
TempSales.setrange("item category code", salesline."item category code")
If TempSales.findset then repeat
TempSales.Amount+=Salesline.Amount
Until TempSales.next=o
Else TempSales:=SalesLine
Until SalesLine.next=o
But tempsales.amount isnt sumamount per item category code. It repeats per line and sumamount is wrong.
Please correct it
Regards,
Undy0 -
Try something like this...
Salesline.reset Salesline.setfilter("document no", "No.") If salesline.findset then repeat TempSales.reset TempSales.setrange("item category code", salesline."item category code") If TempSales.findfirst then begin TempSales."amount including vat" += Salesline."amount including vat"; TempSales.modify; End Else begin TempSales:=SalesLine TempSales.insert; End; Until SalesLine.next=0
1
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