Need to create a temporary table with data from two or three tables, create my own fields in the temp table and key for sorting. I have read about creating temp tables, but based on existing tables. Can someone point me in the right direction.
Thanks
0
Comments
With development license you can create tables with all fields and keys you want.
Tino Ruijs
Microsoft Dynamics NAV specialist
Data Item:
Customer ReqFilterFields Customer Posting Group
Value Entry ReqFilterFields Inventory Posting Group,Posting Date
Integer For reading Temp Table and producing report (not sure about indenting etc)
C/AL Globals:
Item Record Item
ValueEntry Record Value Entry
TempSales Record Temp Sales (Temporary set to yes)
This is where I'm not sure about loading the records into the Temp table to be used in the Integer data item for producing the report. I'm sure this is incorrect:
Value Entry - OnAfterGetRecord()
// Get Item Record
Item.GET("Item No.");
// Load Temporary Table for Report
TempSales.INIT;
TempSales."Entry No." := ValueEntry."Entry No.";
TempSales.Region := Customer."Customer Dimension 1";
TempSales.Model := Item.Model;
TempSales.Series := Item.Series;
TempSales."Item No." := "Item No.";
TempSales."Cust No." := Customer."No.";
TempSales."Inventory Posting Group" := ValueEntry."Inventory Posting Group";
TempSales."Invoiced Quantity" := ValueEntry."Invoiced Quantity";
TempSales."Sales Amount (Actual)" := ValueEntry."Sales Amount (Actual)";
TempSales."Cost Amount (Actual)" := ValueEntry."Cost Amount (Actual)";
TempSales."Discount Amount" := ValueEntry."Discount Amount";
TempSales.INSERT;
Rather new to this so any help would be appreciated.
Thanks
Region Model Invoiced Qty Sales Amount Cost amount
EU 5000 100 3000 1000
EU 6000 200 4000 2000
NA 5000 50 1000 500
NA 6000 150 1500 800
Almost there, just need a little help loading up the temp table.
Thanks
the best solution:
1. create new dataitem with no intendation with source table Integer. Set the TableView with filter Number=FILTER(1..)
2. OnPreDataItem code:
<your temptable>.RESET;
<your temptable>.SETCURRENTKEY(Region, Model);
IF NOT <your temptable>.FINDFIRST THEN
CURRREPORT.BREAK;
3. OnAfterGetRecord code:
IF Number = 1 THEN
<your temptable>.FINDFIRST
ELSE
IF <your temptable>.NEXT = 0 THEN
CURRREPORT.BREAK;
(your code here)
There is a design pattern for this and a How Do I video:
https://www.youtube.com/watch?v=QHn5oEO ... _w&index=8
If you have any more questions, you can also use the design pattern section on the forum.
Thanks for the info much appreciated. I will use that for reading the temp table. I think my code above is incorrect for loading the records into the temp table. When I run I get Temp Sales Entry No '0' Already Exists. Do I need some sort of counter for the records? Also in the Integer dataitem in the OnPreDataItem code, can I use the CurrReport.CREATETOTALS function to create my summary report?
Thanks for you help, alomost there.