DynDeveloper.com

DynDeveloper.com

Sign Up Now!Log In
AsherB 9/18/2009 2:03:58 PM

eConnect Lotted Item Update

Edit 9/17/15 View the main article for this error here 

I have been asked by a customer to send update to Dynamics for SOP transactions, some of which have lotted items. I spent quite some time on it, and then opened up a support case with Microsoft to help me out.

The response is posted below, but the short of it is to delete the SOP line and then readd the line and the lots.

From the response:

Sirs:
I've been looking at this with one of our eConnect developers and there really isn't a way to easily perform an update such as this with reducing the quantity of an existing lot numbered line item. The necessary logic is spread across 2 different stored procedures, the lot and line procs. Unfortunately we can only call one proc at a time and we wind up hitting edit checks in one or the other procedure.

The recommendation for updates such as this is to perform it in a 2-step process. First pass in a taSopLineDelete transaction type to simply remove this line completely from the order. This will wipe out both the line and lot records. Then do your line item update with the line and lot nodes and treat it as though you were appending a new line item to the order. Specifically, ignore the UpdateIfExists field in the Lot node and set UpdateIfExists to 1 in the Line node. This is needed in the line node (even though it's technically a new line item) to flag the call to our recalc proc for the header so that totals on the header can be recalculated.

I did all of my testing in SQL to make it easier to step through the code and records as I went. But here's the final script that successfully removed an existing line item with qty=5 and re-inserted that line with a quantity of 4 with the lot number that I specified. This should give you an idea of the fields that would be needed in your XML at a minimum. With XML you'd be passing the first node, taSopLineDelete, in a separate XML/API call. After that was done, the existing line with Qty=5 would be gone, then you could pass your SOP XML with just the Lot and Line nodes to add the line back in with the correct quantity and lot info.

Here's the script:

set nocount on
declare @O_iErrorState int
declare @oErrString varchar(255)
select @O_iErrorState = 0
begin transaction

if (@O_iErrorState = 0)
begin
 exec taSopLineDelete
  @I_vSOPTYPE = 2,
  @I_vSOPNUMBE = 'ORDST2234',
  @I_vLNITMSEQ = 16384,
  @I_vITEMNMBR = 'CAP100',
  @I_vDeleteType = 1,
  @oErrString = @oErrString output,
  @O_iErrorState = @O_iErrorState output select 'taSopLotAuto Return Code:  '+str(@O_iErrorState)+' Error Code List:  ' +@oErrString end

if (@O_iErrorState = 0)
begin
 exec taSopLotAuto
  @I_vSOPTYPE = 2,
  @I_vSOPNUMBE = 'ORDST2234',
  @I_vLNITMSEQ = 16384,
  @I_vITEMNMBR = 'CAP100',
  @I_vLOCNCODE = 'WAREHOUSE',
  @I_vQUANTITY = 4,
  @I_vLOTNUMBR = 'LOT A',
  @I_vDOCID = 'STDORD',
  @I_vQTYFULFI = 4,
  @I_vALLOCATE = 1,
  @I_vUOFM = 'Each',
  @oErrString = @oErrString output,
  @O_iErrorState = @O_iErrorState output select 'taSopLotAuto Return Code:  '+str(@O_iErrorState)+' Error Code List:  ' +@oErrString end

if (@O_iErrorState = 0)
begin
 exec taSopLineIvcInsert
  @I_vSOPTYPE = 2,
  @I_vSOPNUMBE = 'ORDST2234',
  @I_vCUSTNMBR = 'ADAMPARK0001',
  @I_vITEMNMBR = 'CAP100',
  @I_vDOCDATE = '4/12/2017',
  @I_vLNITMSEQ = 16384,
  @I_vDOCID = 'STDORD',
  @I_vQUANTITY = 4,
  @I_vUNITPRCE = 9.95,
  @I_vDEFEXTPRICE = 1,
  @I_vAUTOALLOCATELOT = 1,
  @I_vUpdateIfExists = 1,
  @I_vUOFM = 'Each',
  @oErrString = @oErrString output,
  @O_iErrorState = @O_iErrorState output select 'taSopLineIvcInsert Return Code:  '+str(@O_iErrorState)+' Error Code List:  ' +@oErrString end if @O_iErrorState <> 0 begin rollback transaction end else begin Commit transaction end select @O_iErrorState,@oErrString

 

Version: Unknown or N/A
Section: eConnect