dd_taSopVoidDocumentWrapper

More and more, I'm seeing the value of calling the eConnect stored procedures directly. There's a lot of overhead in spooling up the .NET code. 

I only do this in lower risk areas... I probably would not normally do a SOP Document because you have to handle so many errors and be sure to back out any lines that you create if there is an error. 

But a SOP Void is easy and painless. I had to do this today for a client, so here it is for your enjoyment. 

Cheers. 

 

IF EXISTS (SELECT name
       FROM   sysobjects
       WHERE  name = N'dd_taSopVoidDocumentWrapper'
       AND    type = 'P')
    DROP PROCEDURE dd_taSopVoidDocumentWrapper
GO
  
  
CREATE PROCEDURE dd_taSopVoidDocumentWrapper
 
--  test code
--  dd_taSopVoidDocumentWrapper 'INVFC0096018',3
  
@I_vSOPNUMBE CHAR(21),
@I_vSOPTYPE SMALLINT
  
AS
  
DECLARE @RC INT
DECLARE @I_vRemovePayments SMALLINT
DECLARE @I_vUSRDEFND1 CHAR(50)
DECLARE @I_vUSRDEFND2 CHAR(50)
DECLARE @I_vUSRDEFND3 CHAR(50)
DECLARE @I_vUSRDEFND4 VARCHAR(8000)
DECLARE @I_vUSRDEFND5 VARCHAR(8000)
DECLARE @O_iErrorState INT
DECLARE @oErrString VARCHAR(255)
DECLARE @dt DATE = GETDATE()
DECLARE @O_iErrorState1 INT = 0
DECLARE @oErrString1 VARCHAR(255) = ''
DECLARE @I_vBACHNUMB VARCHAR(15)
 
--get the batch number so we don't have to pass it in
SELECT @I_vBACHNUMB = h.BACHNUMB
    FROM sop10100 h
    WHERE h.SOPNUMBE = @I_vSOPNUMBE
        AND h.soptype = @I_vSOPTYPE
 
--if the batch number is null, the document is not in the open table and can't be voided
IF @I_vBACHNUMB IS NULL BEGIN
    PRINT 'nothing to do, doc not in open' 
    RETURN
END
 
EXECUTE @RC = taSopVoidDocument
    @I_vSOPTYPE,
    @I_vSOPNUMBE,
    @I_vBACHNUMB = @I_vBACHNUMB,                      
    @I_vRemovePayments = 0,                 
    @I_vVOIDDATE = @dt,
    @I_vUSRDEFND1 = '',                     
    @I_vUSRDEFND2 = '',                     
    @I_vUSRDEFND3 = '',                     
    @I_vUSRDEFND4 = '',                     
    @I_vUSRDEFND5 = '',                     
    @O_iErrorState = @O_iErrorState1 OUTPUT,
    @oErrString = @oErrString1 OUTPUT       
 
--uncomment these lines to see the work happen
 --SELECT @oErrString, @O_iErrorState, voidstts, BACHNUMB FROM sop10100 WHERE sopnumbe = @I_vSOPNUMBE
 --SELECT @oErrString, @O_iErrorState, voidstts, BACHNUMB FROM sop30200 WHERE sopnumbe = @I_vSOPNUMBE
  
 --if the eConnect stored procedure returns an error, raise it
 --gather the error text from dynamics..taErrorCode
if @O_iErrorState > 0 begin
    select @oErrString = ec.ErrorDesc
        from dynamics..taErrorCode ec
        where ec.ErrorCode = @O_iErrorState
    raiserror(@oErrString, 16,2)
END
 
 
GO
  
Grant EXEC on dd_taSopVoidDocumentWrapper to public

RealWorldCode gives developers practical, real‑world solutions with clean, working code — no fluff, no theory, just answers.
Links
Home
Knowledge Areas
Sitemap
Contact
Et cetera
Privacy Policy
Terms and Conditions
Cookie Preferences