To insert records into another table


The scenario is like this

Table1 is like a HEADER table and has the following fields

JournalNo JournalDate JournalBatchName

Table2 is like a DETAIL table and has the following fields

JournalNo GLAccount Document No LineNo. Amount

The link between the 2 tables is the ‘JournalNo’ field

I have a form which displays one record from Header table and the corresponding lines from the detail table.

I need to insert the displayed records into the Gen. Journal Lines table. (81)

We need to take the ‘Journal No’, ‘Journal date’, ‘Journal Batch No’ from the Header table and corresponding lines from the DETAIL table and insert it.

Once we insert it perfectly then we can delete the records from the source table.



Is there a reason why you’re not simply using the General Journal form?

Yes of course,

I am receiving the data into NAV through an XML port,which inserts the data to a header table and a detail table.

Then I am able to display the data to the user via a form, then the user will add certain information like the Batch No etc and once he clicks a button, System shoudl insert these records into the Gen. Journal lines table, so that it becomes available to Accountants, who ever has access to JOURNALS.

This is my idea



Hi TP,

Then you need to write a function/code to insert into the Gen. Journal Line table and don’t forget to validate in the values.


Thanks for the reply.

I know it is a piece of code which will do this.

But I need to know how to write a code for it.

Give me an example and i will do the coding accordingly.

Right now i don’t know how to get started.

I have experience with scripting SQL triggers, Stored procedures etc.

I know the



Hi TP,

Do you have access to a development license?

If so the code you need will be similar to the code in report 1497 - Trans. Bank Rec. to Gen. Jnl. which tranfers entries from a bank reconcilation into a general journal.

Although I would recommend that you get someone with Nav development expoerience involved.


Yes I do have access to the Development license. I shall check the code which you have mentioned in the mail.

Yes I have a friend who has experience in NAV development.

Let me try.



Hi Dave,

I viewed the the code for the report which you had mentioned

Bank Acc. Reconciliation - OnPreDataItem()
SETRANGE(“Bank Account No.”,BankAccRecon.“Bank Account No.”);
SETRANGE(“Statement No.”,BankAccRecon.“Statement No.”);

I understood the above.

But i did not understand the following code, can you please explain

SetBankAccRecon(VAR UseBankAccRecon : Record “Bank Acc. Reconciliation”)
BankAccRecon := UseBankAccRecon;

Hi Thomas,

The SetBankAccRecon is a function which has a parameter of type record for the Bank Acc. Reconciliation table. The function is assigning the BankAccRecon global variable to the record passed down. Without looking at the report/calling function, I assume that this is done to pass the records to the report.