RE: How to create and fill a G/L Register to view all applied entries after running a report?
Hi,
There is of course a number of different ways to do this, and without knowing the customer and exact requirements, here is my ideas, based on the standard application (codeunit 12):
The register is initialized at the beginning of the process:
[Function StartPosting]
GLReg.LOCKTABLE;
IF GLReg.FINDLAST THEN
GLReg."No." := GLReg."No." + 1
ELSE
GLReg."No." := 1;
GLReg.INIT;
GLReg."From Entry No." := NextEntryNo;
GLReg."From VAT Entry No." := NextVATEntryNo;
GLReg."Creation Date" := TODAY;
GLReg."Creation Time" := TIME;
GLReg."Source Code" := "Source Code";
GLReg."Journal Batch Name" := "Journal Batch Name";
GLReg."User ID" := USERID;
IsGLRegInserted := FALSE;
Then during the process, the entry numbers can get incremented as they get processed. And then in the end, the register gets inserted.
I think that this makes it easy to collect all the needed data in the register because anywhere you are applying entries, you can update the register at the same time as you go along. The disadvantage may be performance, since you lock the table during the whole process, so if you need to write this for heavy multi user scenarios, then I would consider another solution of maybe collecting it all into a temp table, but only insert the register at the end of the process.
Just some ideas - again without knowing everything that the process needs to do. Hope it helps.