There are instances where our business users have to add additional PO Lines to a PO that has been fully received. In GP, they can manually change the PO status from Received to Change Order using the Edit Purchase Order Status screen (see screen shot below). We need to be able to do this programmatically. Using eConnect taPOHdr, we've tried updating POSTATUS from 4 to 3, but get Error 8248 (see code and error message below). Does eConnect not support this status change or is there some variable that we are not setting? If eConnect doesn't support this status update, insights on other options such as writing our own stored procedure would be helpful. Thanks!
declare @p1 int
set @p1=168
exec sp_prepexec
@p1 output,N'@P1 smallint,
@P2 datetime2,
@P3 smallint,
@P4 smallint,
@P5 smallint,
@P6 char(18)',
N'BEGIN UPDATE PPDC.dbo.POP10100 SET
POSTATUS = @P1,
LSTEDTDT = @P2,
Revision_Number = @P3,
Change_Order_Flag = @P4,
PO_Status_Orig = @P5
WHERE PONUMBER = @P6
Error Number = 8248 Stored Procedure= taPoLine Error Description = The document has already been received, closed, or canceled. You can not edit a document with a received, closed, or canceled status