Commit in material posting

dietmarruefdietmarruef Member Posts: 48
Hello,

I have to post some material in an routine for posting during the
posting of our addon module. The addon module we have hasn't
any commit's inside but I have problems with the standard posting.

I call the the codeunit 23 Item Jnl.-Post Batch, which is the standard
routine according to posting in Item Journal. This codeunit has some
three commits inside which I disable through a parameterized function
like setHideValdidationDialog. Now my concern is, if I crash some logic
when I disable the commits, on a possible error in the routines?
Has somebody experience?

Already I know about the functionality to just insert into a record variable
the posting information's and run the posting codunit (Codeunit 22) but
the problem in my case is, that I mostly have to book with Serial numbers
and that I can't comprehend how standard Navision passes this information
to the posting codeunit. Just to simply insert the serial no. is not enough.
May somebody knows a solution for this?

Thanks

Dietmar

Comments

  • ara3nara3n Member Posts: 9,256
    before posting the Itemjounral line using CU run the following code and it will create the serial/lot no.

    CreateReservEntry.SetDates(
      0D, 0D);
    
    reateReservEntry.CreateReservEntryFor(
      DATABASE::"Item Journal Line",
      ItemJnlLine."Entry Type",
      ItemJnlLine."Journal Template Name",
      ItemJnlLine."Journal Batch Name",
      0,
      ItemJnlLine."Line No.",
      ItemJnlLine."Qty. per Unit of Measure",
      1,
      '',
      'mylotNo');
    
    CreateReservEntry.CreateEntry(
      ItemJnlLine."Item No.",
      ItemJnlLine."Variant Code",
      ItemJnlLine."Location Code",
      ItemJnlLine.Description,
      ItemJnlLine."Posting Date",
      ItemJnlLine."Document Date",
      0,
      2);
    

    reateReservEntry is a codeunit 99000830 (Create Reserv. Entry)
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • dietmarruefdietmarruef Member Posts: 48
    Hello ara3n!

    Thanks you for the quick reply. I tried to use your code, but it doesn't work. I copied it below. May you have an idea?
    TempJnlLineDim.DELETEALL; 
    
    TempJnlLineDimOrg.RESET;
    TempJnlLineDimOrg.SETRANGE("Table ID",DATABASE::"Item Journal Line");
    TempJnlLineDimOrg.SETRANGE("Journal Template Name",cJournalTemplateName);
    TempJnlLineDimOrg.SETRANGE("Journal Batch Name",cJournalBatchName);
    TempJnlLineDimOrg.SETRANGE("Journal Line No.", LineNo);
    DimMgt.CopyJnlLineDimToJnlLineDim(TempJnlLineDimOrg,TempJnlLineDim);
    
    //ItemJnlLineReserve.CreateReservation(ItemJournalLine,'',TODAY,1,cDeviceID,'');
    CreateReservEntry.SetDates(
      0D, 0D);
    
    CreateReservEntry.CreateReservEntryFor(
      DATABASE::"Item Journal Line",
      ItemJournalLine."Entry Type",
      ItemJournalLine."Journal Template Name",
      ItemJournalLine."Journal Batch Name",
      0,
      ItemJournalLine."Line No.",
      ItemJournalLine."Qty. per Unit of Measure",
      1,
      ItemJournalLine."Serial No.",
      '');
    
    CreateReservEntry.CreateEntry(
      ItemJournalLine."Item No.",
      ItemJournalLine."Variant Code",
      ItemJournalLine."Location Code",
      ItemJournalLine.Description,
      ItemJournalLine."Posting Date",
      ItemJournalLine."Document Date",
      0,
      2); 
    
    ItemJnlPostLine.RunWithCheck(ItemJournalLine,TempJnlLineDimOrg);
    

    The system always shows the error "You must specify Serial No. in Item Journal Template Name ....".

    Thanks in advance

    Kind regards
    Dietmar
  • ara3nara3n Member Posts: 9,256
    what kind of "Entry type" journal line are your posting?

    insert the journal line for testing purposes and don't post it. from the Item journal line form click on line Tracking lines. Do you see the serial no?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • dietmarruefdietmarruef Member Posts: 48
    Hello ara3n!

    Thanks for the reply. I tried now to insert it and after one hour I got
    it to work. The "Serial No." in the journal must be empty. Thanks! :D

    I have one additional question, in this code you posted me and now I implemented
    you always fill status with 0 what is reservation. I had problems before, that this
    caused me errors, because I need to book positive and negative adjustments. May
    you know more, about this.

    Thanks in advance
    Dietmar
  • ara3nara3n Member Posts: 9,256
    I'm sorry I don't understand what you are asking.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • dietmarruefdietmarruef Member Posts: 48
    Hello ara3n!

    Forget about the question, I could resolve it with my finance consultant.

    I am now testing the posting and just saw, that the every posting generates a
    new entry in the item registers. You must know, that I'am posting from a
    document in our vertical solution, that can contain several material entries.
    I tried to create it as a temporary table and pass this to the Codeunit 22 (Item Jnl.-Post Line) - Runwithcheck but it doesn't work. It always just posts the last entry in the table. May you have an idea how I can change the
    routine, that I get just one register entry.

    Thanks in advance,
    Dietmar
  • ara3nara3n Member Posts: 9,256
    make sure you don't clear the variable that you use for CU 22. .
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • dietmarruefdietmarruef Member Posts: 48
    Hello ara3n!

    Thanks a lot, now it works. You safed me a lot of nerves and time.

    Kind regards,
    Dietmar
  • ara3nara3n Member Posts: 9,256
    You are welcome :)
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.