I am attempting to update a Shipment in E9 using code. Here is my Proof of Concept code (not the final version). I’m 90% sure the issue is in how I am creating the before and after record for updating…
/* Declaration has {bo\CustShip\CustShip_ds.i} */
DEF VAR hCustShip AS HANDLE.
RUN bo\CustShip\CustShip.p PERSISTENT SET hCustShip.
DEF BUFFER biShipHead FOR ttShipHead.
for first ShipHead fields (PackNum) no-lock where ShipHead.Company = cur-comp and ShipHead.ReadyToInvoice = false and ShipHead.TrackingNumber ne "",
each ShipVia where ShipVia.Company = ShipHead.Company and ShipVia.ShipViaCode = ShipHead.ShipViaCode and ShipVia.CheckBox01 = true.
message "BEGIN Auto-Ship Pack " + string(ShipHead.PackNum).
RUN GetByID IN hCustShip (input ShipHead.PackNum, {&output_dataset_CustShipDataSet}).
for first ttShipHead.
CREATE biShipHead.
BUFFER-COPY ttShipHead TO biShipHead.
ttShipHead.ShortChar10 = ttShipHead.TrackingNumber.
ttShipHead.RowMod = "U".
end.
CREATE ttShipHead.
BUFFER-COPY biShipHead TO ttShipHead.
RUN Update IN hCustShip ({&input-output_dataset_CustShipDataSet}).
message "END Auto-Ship Pack " + string(ShipHead.PackNum).
end.
Ok, if I’ve followed the idea correctly, this code should work, but it still stops at the Update statement (no error though).
DEF VAR hCustShip AS HANDLE.
RUN bo\CustShip\CustShip.p PERSISTENT SET hCustShip.
DEF BUFFER biShipHead FOR ttShipHead.
for first ShipHead no-lock where ShipHead.Company = cur-comp and ShipHead.ReadyToInvoice = false and ShipHead.TrackingNumber ne "",
each ShipVia where ShipVia.Company = ShipHead.Company and ShipVia.ShipViaCode = ShipHead.ShipViaCode and ShipVia.CheckBox01 = true.
message "BEGIN Auto-Ship Pack " + string(ShipHead.PackNum).
RUN GetByID IN hCustShip (input ShipHead.PackNum, {&output_dataset_CustShipDataSet}).
find first ttShipHead.
if avail ttShipHead then do:
CREATE biShipHead.
BUFFER-COPY ttShipHead TO biShipHead.
end.
ttShipHead.ShortChar10 = "A".
ttShipHead.RowMod = "U".
message "MID Auto-Ship Pack " + string(ShipHead.PackNum).
RUN Update IN hCustShip ({&input-output_dataset_CustShipDataSet}).
message "END Auto-Ship Pack " + string(ShipHead.PackNum).
end.