create and post journal with tracking

BeliasBelias Member Posts: 2,998
hi everyone, do you have an idea on how to achieve the following?

1. populate a journal line variable
2. populate its tracking line(s) and dimensions tables
3. post the journal line

Now, it seems to be a straightforward procedure, but there are 2 catches:

a. i don't want to create a real journal line (i don't want to insert it, i just want to populate a variable as codeunit 80 do, or at least create the journal in a temporary variable). This have to be done for performance and concurrency issues.

b. the tracking lines can be more than one, so, where should i put them? in a temporary variable?if so, will my process be able to read them during the posting of my item journal?

I'm doing some research by myself through standard codeunits, but the tracking module is crappy and i hope someone already figured out how to achieve the same request i have to do. Thanks in advance.
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Comments

  • BeliasBelias Member Posts: 2,998
    I just realized that I can probably do everything with the item journal line only, by making my process work like the SetupSplitJnlLine function in codeunit22 (i don't create reservation entries, but only the journal line with all the tracking fields populated).
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • ara3nara3n Member Posts: 9,256
    That's one of the shortcomings in NAV. The tracking lines have to inserted into the table.

    In order to not insert the actual table, you will need to modify CU 22 and create a new function to pass the temporary tracking lines. Then change SetupSplitJnlLine to get the records from your temporary variable instead of the actual table.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • BeliasBelias Member Posts: 2,998
    yeah, i just realized that codeunit 22 complains here
    TempTrackingSpecification.SETRANGE("Serial No.",ItemJnlLine2."Serial No.");
      TempTrackingSpecification.SETRANGE("Lot No.",ItemJnlLine2."Lot No.");
      IF TempTrackingSpecification.FINDFIRST THEN BEGIN
        ..........
      END ELSE
        IF ItemJnlLine2."Item Charge No." = '' THEN
          IF NOT ItemJnlLine2.Correction THEN // Undo quantity posting.
            ERROR(Text011);
    

    this sucks...i have to create the tracking spec manually...
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • matttraxmatttrax Member Posts: 2,309
    The Create Reserv. Entry Codeunit is your best friend here. Something similar to this as it varies by situation:
    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);
    
  • BeliasBelias Member Posts: 2,998
    I know, I know matt..i've already ABused it...
    but i cannot use that function to create a temporary tracking line, because the CreateEntry creates a REAL Reservation Entry Line. but you gave me a nasty idea...I can condition the INSERT instruction based on a parameter and then create a function to get back the value of the reservation entry in the codeunit.
    After that, it's a straightforward TRANSFERFIELDS on my temporary item tracking line...I'll try it and post the code (I have some concerns about the fact that there are some linked tables, maybe)
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BeliasBelias Member Posts: 2,998
    I think i made it! \:D/ \:D/ \:D/ \:D/ \:D/
    And i think this can make my day, too (I think I can go home after 2 hrs working :) )
    It's not the most clean way to do it, but it's the simpler...but to be honest, I wonder who can be that "clean" when modifying the item tracking module...there's some parameter handshaking between my process --> codeunit "create reserv. entry" --> my process --> codeunit 22
    but it appears to post it fine! I'm <3 it, I'll blog about it ASAP
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • ara3nara3n Member Posts: 9,256
    I think you should suggest it to MS to have the option in CU 22. It's long overdue.
    Ahmed Rashed Amini
    Independent Consultant/Developer


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