BOI IM Transaction Entry Delete Line

SOLVED

Have written a BOI app for scanning pallet tags.
Tag has Pallet ID No., Item, Lot and Qty.

We are doing Sage IM Transaction Entry - Transfers.
We are loading product on one of our trucks to go to our distribution center.

The app is up and running, working well.

I need to modify it as follows:

Let's say they scan 10 pallets onto a truck.
For many different reasons, there is a need to pull one of those pallets off.
The final write has not been done (that may or may not be significant).

Final Write - sage transaction entry header, detail and tier distribution for all the lines entered gets written in one fell swoop.

I can easily toggle a remove function.
They scan the tag and I delete the line from the entry.

my oBUS.oLines.nDeleteLine(SageLineKey) returns a 1 for success but when I do the final write, the line is not deleted.

I go into Sage IM Transaction Entry and locate the Batch and Entry No. and the line is still there.

What else do I have to do to make the delete work?

Also noticed this.
If I enter 3 lines manually using Sage IM Transaction Entry, the line keys are 000001, 000002, 000003.
I'm seeing this in DFDM.
If I scan 3 pallets (it's one per line), the line keys are 000001, 000003, 000005.
Guess BOI likes odd numbers?
Shouldn't matter, they key is the key.

The app is live, in use and working fine.

I capture the line key at this point:

r = oBUS.oLines.nAddLine() 'note: calls SetKey
r = oBUS.Olines.nGetValue("LineKey$", SageLineKey) 'note BOI goes 1,3,5,7 not 1,2,3 like sage entry

I'm collecting the pallet ID and the line key in two arrays:

LineCount = LineCount + 1
PalletIDList(LineCount) = PalletID
SageLineList(LineCount) = SageLineKey

so I can loop to match pallet ID and then I know the line key also in this fashion:

For I = 1 To LineCount
If PalletIDList(I) = PalletID Then
SageLineKey = SageLineList(I)

The delete logic is simply this

r = oBUS.oLines.nDeleteLine(SageLineKey)

and if r<>1 I will get the fail message below:

If r = 1 Then
For I = IStart To LineCount
PalletIDList(I) = PalletIDList(I + 1)
SageLineList(I) = SageLineList(I + 1)
Next I
GoodScans = GoodScans - 1
GoodBad = "remove) "
Call DisplayLast()
MsgL2 = "Pallet Removed "
Call DisplayMsg2()
Call ClearScreen()
Else
MsgL2 = "Delete Pallet ID Failed "
Call DisplayMsg()
End If