Transfering data to a journal

dabba23
Member Posts: 77
I have made a report for processing data from Employee Absence table to a Employee Absence Journal Line.
I simply cannot get the data over, as it complains about the Batch name being empty.
Can anyone see from the code, where I have gone wrong:
Employee Absence - OnPreDataItem()
EmpBatch.GET(EmpJournal."Journal Batch Name");
NextLineNo := 0;
Employee Absence - OnAfterGetRecord()
WITH EmpJournal DO BEGIN
IF NextLineNo = 0 THEN BEGIN
LOCKTABLE;
SETRANGE("Journal Batch Name","Journal Batch Name");
IF FIND('+') THEN
NextLineNo := "Line No.";
END;
NextLineNo := NextLineNo + 1;
INIT;
"Line No." := NextLineNo;
//other code in here, that shouldn't affect the error message!!!
INSERT(TRUE);
END;
Many thanks
Ann
I simply cannot get the data over, as it complains about the Batch name being empty.
Can anyone see from the code, where I have gone wrong:
Employee Absence - OnPreDataItem()
EmpBatch.GET(EmpJournal."Journal Batch Name");
NextLineNo := 0;
Employee Absence - OnAfterGetRecord()
WITH EmpJournal DO BEGIN
IF NextLineNo = 0 THEN BEGIN
LOCKTABLE;
SETRANGE("Journal Batch Name","Journal Batch Name");
IF FIND('+') THEN
NextLineNo := "Line No.";
END;
NextLineNo := NextLineNo + 1;
INIT;
"Line No." := NextLineNo;
//other code in here, that shouldn't affect the error message!!!
INSERT(TRUE);
END;
Many thanks
Ann
0
Comments
-
Could you please tell me what version of navision you are using since I've never seen employee absece with journal batches :?
Well, actualy I have, but I've made these myself0 -
I'm using Navision 3.70, but I have made the journal myself too!!! That's why!0
-
Ah, that explains!
If you use the debugger, where exactly does the error occur?
Does this piece of code go OK?
EmpBatch.GET(EmpJournal."Journal Batch Name");
I am asking this because on first sight I cannot see the problem0 -
Well no, you are rigth that it breaks on EmpBatch.Get(EmpJournal."Journal Batch Name"), which does make sense to me!
However, do I comment it out, it breaks on Emp Absence Jnl Line table on the trigger OnInsert, where I have AbsenceJnlBatch.Get("Journal Batch Name").
Thats why I am lost!0 -
Yes, I guess a journal line wants/can want some journal batch.
How do you start this report? Have you thought about putting the journal batch code in a variable and put it on the request form?
You have to determine where you want to get the batch from.
Is the EmpJournal record populated in the OnPreDataIem or is it empty?
EmpBatch.GET(EmpJournal."Journal Batch Name");
I hope this give you some clues as to where to start searching.0 -
It errors out on GET because there is no such record in the table that you're getting from. To do this without erroring out, you need to make sure that those records are there.
Needing a batch and template for journals is standard Navision functionality. What I usually do is give the user a place to enter a default for both in a setup table and populate the fields with those values.
You can also turn on the debugger and open a standard Journal, and follow standard Navision code to populate the batch and template. That should give you some ideas as to how to develop that.0 -
DenSter wrote:Needing a batch and template for journals is standard Navision functionality. What I usually do is give the user a place to enter a default for both in a setup table and populate the fields with those values.
This is only for journals that are not directly posted, otherwise you can post a journal line without Template/Batch/Line No.
Look at codeunit 80 for example, no templates/batches etc there0 -
I don't think codeunit 80 does an INSERT(TRUE) on the journal line table either (although I'd have to check that).0
-
Yes, this is true, all postings done by navision do no insert the journals, they directly post the line.0
-
So... deducing from the fact that he is using the INSERT method, he's not sending the record into a posting routine, but wants to save the record. The only sensible reason to save a recod is to later access it again. Without a template and a batch, you won't be able to access a standard journal. SO, he needs both of those values.
Elementary my dear Watsonof course unless I'm not paying attention :-k
0 -
Yes, this is true. In this case you need a Batch/Template/Line No.
I just wanted to explain that it can be done without.
I see you've read you Sherlock Holmes 8)
This is getting another highjacked topic...0 -
Basically there is in INIT called, but no code (shown) that fills in a Batch name.
There needs to be code in between the INIT and the INSERT:
INIT;
"batch name" := '..............
INSERT(true);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