IF ReservationEntry.FINDLAST THEN n_reservationentry := ReservationEntry."Entry No." + 1 ELSE n_reservationentry := 1; ReservationEntry.RESET; ReservationEntry."Entry No." := n_reservationentry; ReservationEntry.Positive := TRUE; ReservationEntry."Item No." := EndPurchaseLine."No."; ReservationEntry."Location Code" := EndPurchaseLine."Location Code"; ReservationEntry."Quantity (Base)" := EndPurchaseLine."Qty. to Receive (Base)"; ReservationEntry."Reservation Status" := 2; ReservationEntry.Description := EndPurchaseLine.Description; ReservationEntry."Creation Date" := WORKDATE; ReservationEntry."Source Type" := 39; ReservationEntry."Source Subtype" := 1; ReservationEntry."Source ID" := EndPurchaseLine."Document No."; ReservationEntry."Source Ref. No." := EndPurchaseLine."Line No."; ReservationEntry."Created By" := USERID; ReservationEntry."Qty. per Unit of Measure" := EndPurchaseLine."Qty. per Unit of Measure"; ReservationEntry.Quantity := EndPurchaseLine."Qty. to Receive"; ReservationEntry."Qty. to Handle (Base)" := EndPurchaseLine."Qty. to Receive (Base)"; ReservationEntry."Qty. to Invoice (Base)" := EndPurchaseLine."Qty. to Receive (Base)"; ReservationEntry."Lot No." := EndPurchaseLine."Variant Code"; ReservationEntry."Variant Code" := EndPurchaseLine."Variant Code"; ReservationEntry."Item Tracking" := ReservationEntry."Item Tracking" :: "Lot No."; ReservationEntry.INSERT;
Answers
Edit: by the way, you got your answer already here: http://forum.mibuso.com/discussion/66835/how-to-create-item-tracking-line-for-sales-order-and-transfer-order-through-cal-code#latest
If you want to insert the reservation entries automatically for the user, you have to know where to get the data from and how to handle each scenario. The below example is a simple reception of quantity X on a previously created Lot No.
Also, pay attention to updates in case the user changes the order before posting.
To avoid issues, you might create the tracking lines just before the posting action.
I also recommend checking the purchase or sales order for missing or incoherent data before creating reservation lines based on it. It might also be helpful to delete previous reservation attempts
Best regards,
Sebastien