Need help in Posting Journal Records

Navision : 3.7 Database : SQL Server 2000 SP#3 Windows : 2000 Adv. Server SP#4 Hi Folks, I want to post Journal Records using code unit 12 in a new created dataport. I have written following codes in the OnAfterImportRecord trigger. GenJnlRec."Journal Template Name" := 'GENERAL'; GenJnlRec."Journal Batch Name" := 'IMPORT'; LOCKTABLE; SETRANGE ("Journal Template Name", 'GENERAL'); SETRANGE ("Journal Batch Name", 'IMPORT'); IF FIND ('+') THEN NextLineNo := "Line No." + 10000 ELSE NextLineNo := 10000; GenJnlRec."Line No." := NextLineNo; GenJnlPostLine.RUN (GenJnlRec); In the dataitem properties, Autosave = no, autoupdate = no and autoreplace = no. DataPort properties named FileName has been set to D:\NavDev\BegBal.csv GenJnlRec is variable type Record of table 81 Gen. Journal Line. GenJnlPostLine is variable type Code unit 12 But the problem is “data is not imported to Navision”. [Duh!] Do you know how to resolve this problem? Thanks in advance as always, Jemmy

Save&Compile the dataport and run it from the object designer. don’t run it from c/side. actually you do not need the locking of table and generating of a new “line no.”, because you do not save the General Journal Record, but just post it.

Hi there I might be missing the plot a bit, but it seems as if you are mixing your variables. To my mind you would want to be running Codeunit 12 with a reference to your dataitem, alternatively assign your dataitem to your variable before running CU12 for example: Example 1 - Passing Reference to Dataitem: “Journal Template Name” := ‘GENERAL’; “Journal Batch Name” := ‘IMPORT’; GenJnlPostLine.RUN (“Gen. Journal Line”); Example 2 - Assigning Dataitem to variable, then post: “Journal Template Name” := ‘GENERAL’; “Journal Batch Name” := ‘IMPORT’; GenJnlRec := “Gen. Journal Line”; GenJnlPostLine.RUN (GenJnlRec); Either of these two should work, and you will note that as Gregory pointed out, it is not neccessary to calculate the Line No. as you are posting only a single line at a time. I hope this helps [;)]

I have changed codes to: GenJnlRec.COPY("Gen. Journal Line"); "Journal Template Name" := 'GENERAL'; "Journal Batch Name" := 'IMPORT'; IF GenJnlRec.FIND ('+') THEN NextLineNo := "Line No." + 10000 ELSE NextLineNo := 10000; "Line No." := NextLineNo; "Posting Date" := 061204D; "Document No." := 'IMP-GEN'; GenJnlPostLine.RUN ("Gen. Journal Line"); But I still can post the journal records! [:(] Navision will display warning box written:


The transaction cannot be completed because it will cause inconsistencies in the G/L Entry table. Check where and how the CONSISTENT function is used in the transaction to find the reason for the error.

Do you know how to resolve this… ? [Duh!] Thanks in advance again…

Your error message is due to your Debits not equaling your Credits. Are you posting one transaction at a time or a bunch of journal lines? Why not dataport your entries into a journal and then call the post routine. That way if there are problems you can see the transactions as they came in because they will be sitting in the journal. There is an audit trail via the registers if you use the existing posting routines as well. Django

Yay! I found the problem, looks like it always check the GLEntry and called CONSISTENT function with following expression: BalanceCheckAmount should not be zero (BalanceCheckAmount = 0) [:D] case closed! Thanks folks…