DynDeveloper.com

DynDeveloper.com

Sign Up Now!Log In
scotsun 5/4/2016 8:11:01 AM

Update ITEMNMBR in SO Transaction. Duplicate LNITMSEQ in SOP10200 error !!!

I'm trying to update the Sales Transaction's ITEMNMBR and I'm getting this error "Duplicate LNITMSEQ in SOP10200"

 inside a function I have this code:

Dim doc = XDocument.Parse(strSOPTrans)
'use Linq-to-XML to select just one sop line in the document. 
Dim query = From c In doc.<root>.<eConnect>.<SO_Trans>.<Line>  Select c
'turn it back into a string so we can edit it a little
Dim line As String
For Each element As System.Xml.Linq.XElement In query
RemoveAllInecesaryNodes(element)
line = element.ToString
line = Replace(line, "Line", "taSopLineIvcInsert_ItemsTaSopLineIvcInsert")

Dim sopNumber = element.Element("SOPNUMBE").Value
Dim qty = element.Element("QUANTITY").Value
Dim PRCLEVEL = element.Element("PRCLEVEL").Value
Dim myReader As New StringReader(line)
'Deserialize the XML node from the StringReader into the taSopLineIvcInsert_ItemsTaSopLineIvcInsert object.
Dim oXmlSerializer As New XmlSerializer(GetType(taSopLineIvcInsert_ItemsTaSopLineIvcInsert))
'Cast the deserialized object to a taSopHdrIvcInsert serialization object
Dim otaSopLineIvcInsert As taSopLineIvcInsert_ItemsTaSopLineIvcInsert = CType(oXmlSerializer.Deserialize(myReader), taSopLineIvcInsert_ItemsTaSopLineIvcInsert)
     

With otaSopLineIvcInsert
            .LOCNCODE = newLoc
             .CUSTNMBR = strCUSTNMBR
            .DOCID = strDOCID
            .DOCDATE = strDocDate
             .SOPNUMBE = sopNumber
            .SOPTYPE = SOPTYPE
             .QUANTITY = qty
            .ITEMNMBR = itemnum  ' here I change the item number
             .PRCLEVEL = PRCLEVEL
             otaSopLineIvcInsert.UpdateIfExists = 1
      End With

         itemList.Add(otaSopLineIvcInsert)
Next

and then I do this

 'create the document header
  Dim otaSopHdrIvcInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taSopHdrIvcInsert
'populate the header
      With otaSopHdrIvcInsert
                'these are the required fields
                .SOPNUMBE = strSOPNUMBE
                .SOPTYPE = intSOPTYPE
                .DOCID = strDOCID
                .CUSTNMBR = strCUSTNMBR
                .DOCDATE = dtDocDate
                .BACHNUMB = strBACHNUMB
                .UpdateExisting = 1
                'this is the field that we're updating. 
                .LOCNCODE = loc
                .CSTPONBR = poNum
            End With
'assign the header to the master
oSOPTransactionType.taSopHdrIvcInsert = otaSopHdrIvcInsert
ReDim Preserve oeConnectType.SOPTransactionType(0)
oeConnectType.SOPTransactionType(0) = oSOPTransactionType

Dim xmldoc As Xml.XmlDocument = eConnectOrderToXMLDocument(oeConnectType)
salesOrderDocument = xmldoc.OuterXml

 eConCall.UpdateTransactionEntity(sConnectionString, salesOrderDocument) 'here I got 2 errors

 ERROR 1: Duplicate LNITMSEQ in SOP10200

ERROR 2: LNITMSEQ already exist on a different Item Number

Version: Unknown or N/A
Section: Dynamics GP