Updating Shipment in E9

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.

Please check the program RunBOThru4GL.p under Server/UD/Test directory which has a sample code for this.

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.

Oh man! It was an “Earliest Apply Date” issue…

It is amazing how far reaching just checking the shipped checkbox goes into the system.

Nice. Recently I tried to auto approve a Case Task with the similar code in E9 and it didn’t work both in BPM and external .p program.