Hello, in a lot of integration you have to validate a couple of fields on gen journal before you post it. You are not inserting the genjournal etc. then youc all runwithcheck.
My question is this. You run some validation, which builds this temporary dimemsion using DimMgt codeunit. There is no way for me to get these dimensions. I have to manually create the tempJnlDim and populate it.
So I would like to ask, am I missing something? Most of posting routines, the dimension come from documents, which come from Master tables, and they are not validating any genjournalline fields when they post, which is another story by itself.
So why isn't MS making it clear on how to create a genjournal through code?
I would like to see an example code on how to post a genjournal.
Here is some starting code.
clear(genjournalLine);
genjournaline.validate("Posting Date",workdate);
genjournaline.validate("Document No.",'HAH');
genjournaline.validate("Account Type","Account Type"::"G/L account");
genjournaline.validate("Account No.", 10000);
genjournaline.validate("Amount",100);
genjournaline.Validate("Bal. Account Type","Bal. Account Type"::"G/L account");
genjournaline.Validate("Bal. Account No.",10000);
//how do you populate TempJnlDim without manually populating it with
//default dim or what not. Shouldn't there be a function on
//genjournaLine called GetTempDimensions????
GenJnlPost.runwithCheck(genjournaline,TempJnlDim);
Same applies to Item Journal, job journal, resource journal, FA journal, warehouse journal, bom journal.
Comments
Dynamics West
http://www.dynamicswest.com
For temporary journals, there is no place but to manually create the dimensions.
I'm sure you've written some code that creates a temjournal and posts it.
Would you be kind and post the code on how you create the TempJnlDimension?
Or anybody for that matter.
Anybody?
I can understand the attraction of using a temporary record but I think the sub-tables (such as dimension) will let you down. Unless you create a whole posting routine for the journal it will not "see" your temporary dim tables. What I suggest is to create a batch for this posting and write the line to the batch. You would not have to commit the line so if (when ) the posting routine hits a problem it will roleback the entire posting.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
What if somebody inserts other records into the batch.
You then have to deal with SIFT tables being populated which is not needed.
So I'm guessing nobody here ever created a journal line and posted it with dimensions?
Example from Codeunit 80:
The dimensions have already been put into TempDocDim, when suddenly:
ResJnlLine.INIT;
ResJnlLine."Posting Date" := "Posting Date";
ResJnlLine.x = y etc., etc.
(notice there is NO insert here)
TempJnlLineDim.DELETEALL;
TempDocDim.RESET;
TempDocDim.SETRANGE("Table ID",DATABASE::"Sales Line");
TempDocDim.SETRANGE("Line No.",SalesLine."Line No.");
DimMgt.CopyDocDimToJnlLineDim(TempDocDim,TempJnlLineDim);
ResJnlPostLine.RunWithCheck(ResJnlLine,TempJnlLineDim);
Dynamics West
http://www.dynamicswest.com
And the above quote states the exact thing.
One of main points in Navision is to validate the fields so business logic is run, if you are not doing this, it's as good as writing sql statements and asking thirdparty to insert into the journal table directly, and let Navision post it.
RIS Plus, LLC
It's also not good for performance reasons, Locking. etc
It's the right way to post journals, because that's how it's done thoughout the system. Journal tables shouldn't have any SIFT. If your really worried about other people entering lines into your batch, you could always restrict certain (types of) batches.
Tell me exactly what is bad for performance about this solution?
RIS Plus, LLC
If you that worried about other people using the same batch you can filter to just your line no. and post this it that way - just as it works manually.
Dynamics Nav Add-ons
http://www.simplydynamics.ie/Addons.html
So you are telling me that everybody here inserts the journal line into the table. The grabs the journal dimension that it creates and posts it with run with check?
I'd rather create the dimension manually than use this solution. If you are posting 20000 lines, you won't have the luxury to insert into a table that you don't need to.
Creating the journal and posting it is the standard accepted way of posting journals programmatically. If you manage the template/batches well, it's not going to be a problem. Now with the transactino volume that you are now talking about, that might become a problem, it might not be, you can't tell ahead of time.
I seriously doubt that creating 20000 records in memory, plus all related dimensions is the right solution either, and you know it isn't either or you wouldn't ask for help. I would probably start thinking more along the lines of storing the journals in the table, locking certain template/batch combinations, and letting a NAS post the journals.
Anyway, this is my last contribution to this thread, good luck in figuring this out.
RIS Plus, LLC