Adjust cost routine
redking
Member Posts: 34
Hi Guys,
Bit of background: I am not a NAV expert at all but I have just started at a new company as their IT admin.
They use NAV 2009 R2 but have parted ways (before I left) with the Partner due to their incompetence apparantly.
My boss has asked my to see if I could fix the Job Queue which doesn't run at all (can't figure out why just yet). There is a codeunit with code for several jobs and one "section" is to do with adjust costs.
Now, reading the manual there is inbuilt stuff in NAV to do Adjust Costs - Automatic Cost Adjustment & Adjust Cost Item Entries (i've yet to understand how they work but I've found the white paper) but the code used by the old Partner is this:
ItemApplnEntry.LOCKTABLE;
IF NOT ItemApplnEntry.FIND('+') THEN
EXIT;
ItemLedgEntry.LOCKTABLE;
IF NOT ItemLedgEntry.FIND('+') THEN
EXIT;
AvgCostAdjmtEntryPoint.LOCKTABLE;
IF AvgCostAdjmtEntryPoint.FIND('+') THEN;
ValueEntry.LOCKTABLE;
IF NOT ValueEntry.FIND('+') THEN
EXIT;
PostToGL:=TRUE;
IF ItemNoFilter <> '' THEN
Item.SETFILTER("No.",ItemNoFilter);
IF ItemCategoryFilter <> '' THEN
Item.SETFILTER("Item Category Code",ItemCategoryFilter);
InvtAdjmt.SetProperties(FALSE,PostToGL);
InvtAdjmt.SetFilterItem(Item);
InvtAdjmt.MakeMultiLevelAdjmt;
UpdateItemAnalysisView.UpdateAll(0,TRUE);
Can anyone tell me what this code does?
Is it neccessary?
Can I use the inbuilt stuff in it's place?
Thanks for any feed back!
Bit of background: I am not a NAV expert at all but I have just started at a new company as their IT admin.
They use NAV 2009 R2 but have parted ways (before I left) with the Partner due to their incompetence apparantly.
My boss has asked my to see if I could fix the Job Queue which doesn't run at all (can't figure out why just yet). There is a codeunit with code for several jobs and one "section" is to do with adjust costs.
Now, reading the manual there is inbuilt stuff in NAV to do Adjust Costs - Automatic Cost Adjustment & Adjust Cost Item Entries (i've yet to understand how they work but I've found the white paper) but the code used by the old Partner is this:
ItemApplnEntry.LOCKTABLE;
IF NOT ItemApplnEntry.FIND('+') THEN
EXIT;
ItemLedgEntry.LOCKTABLE;
IF NOT ItemLedgEntry.FIND('+') THEN
EXIT;
AvgCostAdjmtEntryPoint.LOCKTABLE;
IF AvgCostAdjmtEntryPoint.FIND('+') THEN;
ValueEntry.LOCKTABLE;
IF NOT ValueEntry.FIND('+') THEN
EXIT;
PostToGL:=TRUE;
IF ItemNoFilter <> '' THEN
Item.SETFILTER("No.",ItemNoFilter);
IF ItemCategoryFilter <> '' THEN
Item.SETFILTER("Item Category Code",ItemCategoryFilter);
InvtAdjmt.SetProperties(FALSE,PostToGL);
InvtAdjmt.SetFilterItem(Item);
InvtAdjmt.MakeMultiLevelAdjmt;
UpdateItemAnalysisView.UpdateAll(0,TRUE);
Can anyone tell me what this code does?
Is it neccessary?
Can I use the inbuilt stuff in it's place?
Thanks for any feed back!
0
Comments
-
The code you posted is basically the standard code. So switching to the "standard code" is likely not going to solve your issue. Can you expand on "doesn't run at all"? What (if any) errors are being logged by Job Queue.There are no bugs - only undocumented features.0
-
bbrown wrote:The code you posted is basically the standard code. So switching to the "standard code" is likely not going to solve your issue. Can you expand on "doesn't run at all"? What (if any) errors are being logged by Job Queue.
Hi BBrown,
the real problem is that the job queue seems stop completely with nothing appearing in the Job Queue log. Sometimes, we can "kick" them in to life by changing the "Earliest Start Date / Time" but only sometimes.
Any thoughts?0 -
Would need more details. Are we sure we don't just have an issue with NAS? Is "Adjust Cost" its own entry in the Job Queue? With other entries for other task. Or is there just 1 big entry that is doing several things.There are no bugs - only undocumented features.0
-
bbrown wrote:Would need more details. Are we sure we don't just have an issue with NAS? Is "Adjust Cost" its own entry in the Job Queue? With other entries for other task. Or is there just 1 big entry that is doing several things.
Hi,
this is the code in codeunti 25000
Documentation()
OnRun(VAR Rec : Record "Job Queue Entry")
CASE "Parameter String" OF
'DailyInvoiceReport':DailyInvoiceReport;
'AdjustCosts':AdjustCosts;
END;
DailyInvoiceReport()
FileName:=RBMgt.ServerTempFileName('','.htm');
IF EXISTS(FileName) THEN
ERASE(FileName);
OrdersListReport.SAVEASHTML(FileName);
ReportDate:=CALCDATE('-1D',WORKDATE);
SenderName:='NAS';
SenderAddress:='domain@domain.com';
Recipients:='1stperson@domain.com;2ndperson@domain.com;3rdperson@domain.com';
Subject:=STRSUBSTNO('Orders and Invoices report on %1',ReportDate);
SMTPMail.CreateMessage(SenderName,SenderAddress,Recipients,Subject,'',TRUE);
SMTPMail.AddAttachment(FileName);
{
SMTPMail.AppendBody('<table>');
LineText:=STRSUBSTNO('<tr><td>%1</td><td align=right>%2</td><td align=right>%3</td></tr>',
'Invoice No.','Customer No.','Sales Value');
SalesInvoice.SETRANGE("Posting Date",ReportDate);
IF SalesInvoice.FINDSET THEN REPEAT
SalesInvoice.CALCFIELDS(Amount);
InvoiceTotal+=SalesInvoice.Amount;
LineText:=STRSUBSTNO('<tr><td>%1</td><td align=right>%2</td><td align=right>%3</td></tr>',SalesInvoice."No.",
SalesInvoice."Sell-to Customer No.",
FORMAT(SalesInvoice.Amount,0,'<Precision,2><standard format,1>'));
SMTPMail.AppendBody(LineText);
UNTIL SalesInvoice.NEXT=0;
SalesCredit.SETRANGE("Posting Date",ReportDate);
IF SalesCredit.FINDSET THEN REPEAT
SalesCredit.CALCFIELDS(Amount);
InvoiceTotal-=SalesCredit.Amount;
LineText:=STRSUBSTNO('<tr><td>%1</td><td align=right>%2</td><td align=right>%3</td></tr>',SalesCredit."No.",
SalesCredit."Sell-to Customer No.",
FORMAT(SalesInvoice.Amount,0,'<Precision,2><standard format,1>'));
SMTPMail.AppendBody(LineText);
UNTIL SalesCredit.NEXT=0;
LineText:=STRSUBSTNO('<tr><td>%1</td><td></td><td align=right>%2</td></tr>','Total',
FORMAT(InvoiceTotal,0,'<Precision,2><standard format,1>'));
SMTPMail.AppendBody(LineText);
SMTPMail.AppendBody('</table>');
}
SMTPMail.Send;
AdjustCosts()
ItemApplnEntry.LOCKTABLE;
IF NOT ItemApplnEntry.FIND('+') THEN
EXIT;
ItemLedgEntry.LOCKTABLE;
IF NOT ItemLedgEntry.FIND('+') THEN
EXIT;
AvgCostAdjmtEntryPoint.LOCKTABLE;
IF AvgCostAdjmtEntryPoint.FIND('+') THEN;
ValueEntry.LOCKTABLE;
IF NOT ValueEntry.FIND('+') THEN
EXIT;
PostToGL:=TRUE;
IF ItemNoFilter <> '' THEN
Item.SETFILTER("No.",ItemNoFilter);
IF ItemCategoryFilter <> '' THEN
Item.SETFILTER("Item Category Code",ItemCategoryFilter);
InvtAdjmt.SetProperties(FALSE,PostToGL);
InvtAdjmt.SetFilterItem(Item);
InvtAdjmt.MakeMultiLevelAdjmt;
UpdateItemAnalysisView.UpdateAll(0,TRUE);
The first bit sends a report to certain people. There is a problem with this bit as I cannot add or remove any email addresses. It just stop working completely.
The second bit is the adjust cost stuff0 -
Every time you make a change to this code (add remove contacts) you need to restart NAS to take the changes.
Also any user using Classic client must do the same.
Regarding Adjust cost, you must check all the prerequisites to see why it doesn't run.
you can run Adjust cost manually and see if you receive any error.
You must also make sure that NAS is not running in parallel with other jobs and table locking's occur at the same time.
One solution would be to run at the same time like NAS is doing the procedure manually (disable NAS) and you can see if on that time something else is happening (which is very possible since when you are running the procedure on different time some times it does run)0
Categories
- All Categories
- 73 General
- 73 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 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