Create ItemJnlLine with LotNo and Post via Codeunit

jordi79jordi79 Member Posts: 275
Hi,

I am trying to create an ItemJnlLine with ItemTrackingSpecification and Post. All this is done via Codeunit.

What I have coded is below:
ItemJnlLine.INIT;
ItemJnlLine.VALIDATE("Posting Date", TODAY);
ItemJnlLine.VALIDATE("Document No.", 'QWERTY1111');
ItemJnlLine.VALIDATE(ItemJnlLine."Entry Type", ItemJnlLine."Entry Type"::"Negative Adjmt.");
ItemJnlLine.VALIDATE("Item No.", 'LOTITEM');
ItemJnlLine.VALIDATE("Location Code", 'DEFAULT');
ItemJnlLine.VALIDATE(Quantity, 1);

TempJnlLineDim.RESET;
TempJnlLineDim.DELETEALL;

TempTrackingSpec.RESET;
TempTrackingSpec.DELETEALL;
// not sure how to specify TempTrackingSpec and pass to ItemJnlPostLine codeunit for posting!!!

ItemJnlPostLine.RunWithCheck(ItemJnlLine, TempJnlLineDim);

Item LOTITEM, is a LotSpecific Tracking Item. I have no idea how to pass Tracking Specification table into ItemJnlPostLine. I know that if I were to insert
"actual" TempTrackingSpecification records, I am able to post. But this of course is not the way to go. I was hoping of somehow to pass TrackingSpec records into ItemJnlPostLine, like how TempJnlLineDim is passed to ItemJnlPostLine Codeunit.

Jordan

Comments

  • ara3nara3n Member Posts: 9,256
    You need to create reservation entry. NAV in CU 22 grabs them and creates tracking lines.

    Here is code on how to create the reservation entry.
    CreateReservEntry = CU 99000830 Create Reserv. Entry
    CreateReservEntry.SetDates(
      0D, 0D);
    
    CreateReservEntry.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,
      SerialNo,
      '');
    
    CreateReservEntry.CreateEntry(
      ItemJnlLine."Item No.",
      ItemJnlLine."Variant Code",
      ItemJnlLine."Location Code",
      ItemJnlLine.Description,
      ItemJnlLine."Posting Date",
      ItemJnlLine."Document Date",
      0,
      2);
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • jordi79jordi79 Member Posts: 275
    Hi,

    Thanks. It is working now.

    Jordan
  • 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.