Adding a Tracking Spec Line through AL Code?

mysamzamysamza Member Posts: 66
rec_trackingspec.init();

                                                      if rec_trackingspec2.FindLast() then
                                                          rec_trackingspec."Entry No." := rec_trackingspec2."Entry No." + 1 else
                                                          rec_trackingspec."Entry No." := 1;
                                                     

                                                      rec_trackingspec."Creation Date" := WorkDate();
                                                      rec_trackingspec.Positive := true;
                                                      rec_trackingspec.Validate("Item No.", rec_SalesLine."No.");
                                                      rec_trackingspec.Validate("Lot No.", rec_itemledgerentry."Lot No.");
                                                      rec_trackingspec."Location Code" := 'MAIN';
                                                
                                                      rec_trackingspec.Validate("Quantity (Base)", rec_SalesLine.Quantity);
                                                      rec_trackingspec.Validate("Bin Code", rec_SalesLine."Bin Code");
                                                      rec_trackingspec."Source Ref. No." := rec_SalesLine."Line No.";
                                                
                                                      rec_trackingspec.Insert(true);

Checking through debugger, I see Insert(true) gets executed, however when i go to check if Tracking Spec has the line I intended to insert, it does not show the entry there.

Answers

  • mysamzamysamza Member Posts: 66
    I am trying to add Tracking Spec entry through code above
  • ResolusResolus Member Posts: 40
    What do you want to achieve/what is your goal?
  • mysamzamysamza Member Posts: 66
    @Resolus I want to eventually go search for the Item line from Sales Order and see in Item Ledger Entries if the Item qty on Sales Order is less than the remaining amount from ILE then I want to pick the LOT NO. in from ILE and drop the line in Tracking Specification of that Item in Sales Order. Basically automate Lot No. allocation of all Sales Order lines verifying remaining qty from ILE. For now, I am just trying to write code to insert, which isn't working as mentioned above.
  • AlexeyShaminAlexeyShamin Member Posts: 80
    edited 2020-09-08
    Hello! for Item Tracking you need create entry in Reservation Entry Table.


    Exampe for Sales Order:
    https://forum.mibuso.com/discussion/comment/332040#Comment_332040

  • mysamzamysamza Member Posts: 66
    2. PurchReservEntry.InitTrackingSpecification(PurchLIne, NewTrackingSpecification); This line init NewTrackingSpecification for Purch Line @AlexeyShamin here my first parameter would be sales line, however, where do I have to bring NewTrackingSpecification from?
  • AlexeyShaminAlexeyShamin Member Posts: 80
    Sorry Example for Purch Order.
    For Sales Order use codeunit Sales Line-Reserve (99000834) instead of Purch. Line-Reserve (99000834) (PurchReservEntry)
Sign In or Register to comment.