Dialog 2013r2

gonzy1981gonzy1981 Member Posts: 156
Hi there,
I'm working with a vertical solution in 2009 r2 and I am Upgrading the solution to 2013 r2 to my new clients, and there is one thing that i dont know how to sort it out.

Let me explain:
I have a codeunit 50000, with around ten funcions and each of these functions are posting genjnlline--> calling to the codeunit 13 (Gen. Jnl.-Post-Batch), but in my codeunit 50000 I've a dialog which says the user which "Document No." is posting and in which function is him, pretty helpfull. But, in the NAV 2013 R2 when there is a error in the codeunit 13 my dialog is automatic closed, so the user only has a weird error which he doesn't understand and this error doesn't informn the user in which document is the problem. In 2009, this dialog used to keep open.

I've been thinking about to put in my codeunit 50000:
.
.
.
GenJnlLine.INSERT(TRUE);
.
.
GenJnlLine.MODIFY(TRUE);

IF NOT GenJnlBatchPostLine.RUN(GenJnlLine) THEN
ERROR(Text50000,GenJnlLine.TABLECAPTION,GenJnlLine."Document No.",GETLASTERRORTEXT)

But it breaks, due to the fact that before the GenJnlBatchPostLine.RUN(GenJnlLine) i should put a COMMIT-->But I cannot put that sentence there (thats crazy).

Could you give me a any advice?? Do you know how can I sort it out?
Thanks

Gonzalo

Comments

  • SiStSiSt Member Posts: 46
    Do you need the custom error message that is created with the help of Text50000?
    If not you can call the "GenJnlBatchPostLine.RUN(GenJnlLine)" statement without the if and comment the error message below. If there is an error it will break with the default error message. Else it will work like before.
  • gonzy1981gonzy1981 Member Posts: 156
    Hi Sist,

    In my codeunit 50000, It's been posting a lot of records, with different "Document No." and sometimes, the nav default errors show us which is the "Document No." which has an error, but in an other situations the default error doesn't say in which document no. is the error, and that is a pain in my ....

    Do you see my problem????
  • ReinhardReinhard Member Posts: 249
    hi gonzy,
    yes I see your problem. the error normally may be something like "Posting Group must not be blank." but it doesn't indicate which one of the thousands of possible documents it applies to.
    I think your solution is sound.

    I'm confused by this:
    But it breaks, due to the fact that before the GenJnlBatchPostLine.RUN(GenJnlLine) i should put a COMMIT-->But I cannot put that sentence there (thats crazy).

    Can you be more specific? How does it break? Why do you need a commit?

    Personally, I would... first, create all the journal lines. Then, batch post them. This way only the ones with errors will be left over, and the user knows they must resolve these manually.

    Also as a side note, I think I read before that for "post line" codeunits, you don't actually need to insert the journal line at all. just filling it in and passing it in should suffice. This way you don't have to start the write transaction prior to posting.

    - Reinhard
  • gonzy1981gonzy1981 Member Posts: 156
    Hi Reinhard,
    Thtat's exactly my headache!!!

    Yes, what a I mean is:
    When I write the sentence:

    .
    .

    .
    .
    .
    GenJnlLine.INSERT(TRUE);

    IF NOT GenJnlBatchPost(GenJnlLine) THEN
    ... GETLASTERRORTEXT

    Its compulsory write before the IF a COMMIT, otherwise I'll receive a error from NAV. And I cannot write a COMMIT there because just before calling GenJnlBatchPost.RUN I'm modifing my vertical documents to Post = TRUE and if the codeunit 13 breaks the COMMIT will have changed for ever my vertical document to TRUE and I'll have a lot of records in the GenJnlLine without posting too. ](*,) ](*,) ](*,) ](*,) ](*,) ](*,)

    Ring me bells about your side note, I'll check!
  • KeeperRUKeeperRU Member Posts: 58
    You cannot use "return value" with Codeunit.RUN, if earlier you start transaction to physical database.
    But you can do all that you want with TEMPORARY tables.

    GenJnlTMP."Line No" := 10000;
    ....
    GenJnlTMP.INSERT;

    JournalLineDimTMP.....
    JournalLineDimTMP.INSERT;

    GenJnlBatchPostLine.SetPostTMP(GenJnlTMP, JournalLineDimTMP); //----Write your own function
    IF NOT GenJnlBatchPostLine.RUN(GenJnlLine) THEN
    ERROR(Text50000,GenJnlLine.TABLECAPTION,GenJnlLine."Document No.",GETLASTERRORTEXT)

    You also need to write code on RUN to transfer from TEMP to REAL tables.
Sign In or Register to comment.