Inserting lines into the journal line table

Soloper
Member Posts: 102
Hi all again;
I searched the forum but couldnt find the solution.
I am trying to insert sum records which are collected from G/L Entry table into the journal line. But it adds only one record and if there is another one it gives the following error :
----
The Gen. Journal Line already exists.
Identification fields and values :
Journal Template Name='TEMP1', Journal Batch Name="TEMPBATCH", Line No.='0'
----
I think the porblem is with the line no. It increase by one for every single record but it keeps 0 for line no and crush.
The code is below :
SourceTable for the form is G/L Entry
I searched the forum but couldnt find the solution.
I am trying to insert sum records which are collected from G/L Entry table into the journal line. But it adds only one record and if there is another one it gives the following error :
----
The Gen. Journal Line already exists.
Identification fields and values :
Journal Template Name='TEMP1', Journal Batch Name="TEMPBATCH", Line No.='0'
----
I think the porblem is with the line no. It increase by one for every single record but it keeps 0 for line no and crush.
The code is below :
SourceTable for the form is G/L Entry
IF Rec.FINDFIRST THEN;
REPEAT
JournalLine.INIT;
JournalLine."Journal Template Name":='TEMP1';
JournalLine.VALIDATE("Journal Template Name");
JournalLine."Journal Batch Name" := 'TEMPBATCH';
JournalLine.VALIDATE("Journal Batch Name");
JournalLine."Account Type":= 0;
JournalLine.VALIDATE("Account Type");
JournalLine."Account No.":="G/L Account No.";
JournalLine.VALIDATE("Account No.");
JournalLine."Posting Date":= "Posting Date";
JournalLine.VALIDATE("Posting Date");
JournalLine."Credit Amount":=Amount;
JournalLine.VALIDATE("Credit Amount");
JournalLine."Bal. Account Type" := 3;
JournalLine.VALIDATE("Bal. Account Type");
JournalLine."Bal. Account No." := BankAccount."No.";
JournalLine.VALIDATE("Bal. Account No.");
JournalLine.INSERT;
UNTIL Rec.NEXT = 0;
0
Answers
-
IF Rec.FINDFIRST THEN;
REPEAT
JournalLine.INIT;
JournalLine."Journal Template Name":='TEMP1';
JournalLine.VALIDATE("Journal Template Name");
JournalLine."Journal Batch Name" := 'TEMPBATCH';
JournalLine.VALIDATE("Journal Batch Name");
JournalLine.INSERT;
UNTIL Rec.NEXT = 0;
you have to insert line no for each record like..
GenJnlLine."Line No." := GenJnlLine."Line No." + 10000;
because line no is also part of PK..
Vijay Gupta0 -
Works..
Thanks Vijay.0 -
never use FINDFIRST with REPEAT UNTIL. [-X
This is a MUST KNOW for all developers...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