eConnect - POP Receivings Type with Lots

This is a complete code example for the POPReceivingsType schema, showing how to receive lotted items.

 

 

Function POPReceiptWithLots(POPRCTNM As String, POPTYPE As Int16, strSQLServer As String, strDatabase As String) As String
    'this is a complete working example for the POPReceivingsType schema, showing how to receive lotted items
 
    'we expect there to be three tables populated:
    'DDtaPopRcptLineInsert
    'DDtaPopRcptHdrInsert
    'DDtaPopRcptLotInsert
    'the POPRCTNM and POPTYPE parameters can be used to query the data out of those tables
 
    'The fields in these tables are all NULLABLE. The script to create these tables is located here:
    'if you don't populate a field in the table it won't be used. Only populated values are imported.
 
    'this code also makes use of the CDBNull Method, documented here:
 
    'set the return value for the function
    POPReceiptWithLots = ""
 
    'initialize
    Dim intLineCount As Int16
    Dim intDistLineCount As Int16
    Dim strResult As String = ""
 
    Try
        'Create eConnect Objects
        'the eConnectFunctions class is documented here:http://dyndeveloper.com/thread.aspx?Threadid=1117
        Dim oeConnectFunctions As New eConnectFunctions(strSQLServer, strDatabase)
        Dim oeConnectType As New Microsoft.Dynamics.GP.eConnect.Serialization.eConnectType
        Dim oPOPReceivingsType As New Microsoft.Dynamics.GP.eConnect.Serialization.POPReceivingsType
 
        '=======================================================================
        'lines
        '=======================================================================
        'data access code that queries the DDtaPopRcptLineInsert table and returns a DataTable
        For Each oRow As DataRow In DAL.SPs.dd_DDtaPopRcptLineInsert_SEL_byID2(POPTYPE, POPRCTNM).getTable.Rows
            'create an eConnect object to hold the line info
            Dim otaPopRcptLineInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taPopRcptLineInsert_ItemsTaPopRcptLineInsert
            'populate the object. If the field in the table is null, then assign the field to itself. Otherwise, assign the value
            With otaPopRcptLineInsert
                .ACTLSHIP = CDBNull(.ACTLSHIP, oRow("ACTLSHIP"))
                .AutoAssignBin = CDBNull(.AutoAssignBin, oRow("AutoAssignBin"))
                .AUTOCOST = CDBNull(.AUTOCOST, oRow("AUTOCOST"))
                .BOLPRONUMBER = CDBNull(.BOLPRONUMBER, oRow("BOLPRONUMBER"))
                .CMMTTEXT = CDBNull(.CMMTTEXT, oRow("CMMTTEXT"))
                .CostCatID = CDBNull(.CostCatID, oRow("CostCatID"))
                .CURNCYID = CDBNull(.CURNCYID, oRow("CURNCYID"))
                .EXTDCOST = CDBNull(.EXTDCOST, oRow("EXTDCOST"))
                If Not oRow("EXTDCOST") Is System.DBNull.Value Then
                    .EXTDCOSTSpecified = True
                End If
                .InventoryAccount = CDBNull(.InventoryAccount, oRow("InventoryAccount"))
                .INVINDX = CDBNull(.INVINDX, oRow("INVINDX"))
                .ITEMDESC = CDBNull(.ITEMDESC, oRow("ITEMDESC"))
                .ITEMNMBR = CDBNull(.ITEMNMBR, oRow("ITEMNMBR"))
                .JOBNUMBR = CDBNull(.JOBNUMBR, oRow("JOBNUMBR"))
                .Landed_Cost_Group_ID = CDBNull(.Landed_Cost_Group_ID, oRow("Landed_Cost_Group_ID"))
                .LOCNCODE = CDBNull(.LOCNCODE, oRow("LOCNCODE"))
                .NONINVEN = CDBNull(.NONINVEN, oRow("NONINVEN"))
                .POLNENUM = CDBNull(.POLNENUM, oRow("POLNENUM"))
                .PONUMBER = CDBNull(.PONUMBER, oRow("PONUMBER"))
                .POPRCTNM = CDBNull(.POPRCTNM, oRow("POPRCTNM"))
                .POPTYPE = CDBNull(.POPTYPE, oRow("POPTYPE"))
                .ProjNum = CDBNull(.ProjNum, oRow("ProjNum"))
                .Purchase_Item_Tax_Schedu = CDBNull(.Purchase_Item_Tax_Schedu, oRow("Purchase_Item_Tax_Schedu"))
                .Purchase_IV_Item_Taxable = CDBNull(.Purchase_IV_Item_Taxable, oRow("Purchase_IV_Item_Taxable"))
                .Purchase_Site_Tax_Schedu = CDBNull(.Purchase_Site_Tax_Schedu, oRow("Purchase_Site_Tax_Schedu"))
                .QTYINVCD = CDBNull(.QTYINVCD, oRow("QTYINVCD"))
                .QTYSHPPD = CDBNull(.QTYSHPPD, oRow("QTYSHPPD"))
                .RCPTLNNM = CDBNull(.RCPTLNNM, oRow("RCPTLNNM"))
                .receiptdate = CDBNull(.receiptdate, oRow("receiptdate"))
                .RequesterTrx = CDBNull(.RequesterTrx, oRow("RequesterTrx"))
                .TAXAMNT = CDBNull(.TAXAMNT, oRow("TAXAMNT"))
                .VENDORID = CDBNull(.VENDORID, oRow("VENDORID"))
                .VNDITDSC = CDBNull(.VNDITDSC, oRow("VNDITDSC"))
                .VNDITNUM = CDBNull(.VNDITNUM, oRow("VNDITNUM"))
                .UNITCOST = CDBNull(.UNITCOST, oRow("UNITCOST"))
                If Not oRow("UNITCOST") Is System.DBNull.Value Then
                    .UNITCOSTSpecified = True
                End If
                .UOFM = CDBNull(.UOFM, oRow("UOFM"))
                .USRDEFND1 = CDBNull(.USRDEFND1, oRow("USRDEFND1"))
                .USRDEFND2 = CDBNull(.USRDEFND2, oRow("USRDEFND2"))
                .USRDEFND3 = CDBNull(.USRDEFND3, oRow("USRDEFND3"))
                .USRDEFND4 = CDBNull(.USRDEFND4, oRow("USRDEFND4"))
                .USRDEFND5 = CDBNull(.USRDEFND5, oRow("USRDEFND5"))
 
                'Data access code to delete the line that we just used from DDtaPopRcptLineInsert
                SPs.dd_DDtaPopRcptLineInsert_DEL_byID(oRow("RowID")).execute()
 
                'add the line to the POPReceivingsType object
                ReDim Preserve oPOPReceivingsType.taPopRcptLineInsert_Items(intLineCount)
                oPOPReceivingsType.taPopRcptLineInsert_Items(intLineCount) = otaPopRcptLineInsert
                intLineCount += 1
 
                '=======================================================================
                'lots
                '=======================================================================
                intDistLineCount = 0
                'data access code that queries the DDtaPopRcptLotInsert table and returns a DataTable
                For Each oRowLot As DataRow In DAL.SPs.dd_DDtaPopRcptLotInsert_SEL_byID2(POPRCTNM, oRow("RCPTLNNM")).getTable.Rows
                    'create an eConnect object to hold the line lot info
                    Dim otaPopRcptLotInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taPopRcptLotInsert_ItemsTaPopRcptLotInsert
                    'populate the object. If the field in the table is null, then assign the field to itself. Otherwise, assign the value
                    With otaPopRcptLotInsert
                        .POPRCTNM = CDBNull(.POPRCTNM, oRowLot("POPRCTNM"))
                        .ITEMNMBR = CDBNull(.ITEMNMBR, oRowLot("ITEMNMBR"))
                        .SERLTNUM = CDBNull(.SERLTNUM, oRowLot("SERLTNUM"))
                        .SERLTQTY = CDBNull(.SERLTQTY, oRowLot("SERLTQTY"))
                        .RCPTLNNM = CDBNull(.RCPTLNNM, oRowLot("RCPTLNNM"))
                        .BIN = CDBNull(.BIN, oRowLot("BIN"))
                        .CREATEBIN = CDBNull(.CREATEBIN, oRowLot("CREATEBIN"))
                        .LOCNCODE = CDBNull(.LOCNCODE, oRowLot("LOCNCODE"))
                        .EXPNDATE = CDBNull(.EXPNDATE, oRowLot("EXPNDATE"))
                        .MFGDATE = CDBNull(.MFGDATE, oRowLot("MFGDATE"))
                        .RequesterTrx = CDBNull(.RequesterTrx, oRowLot("RequesterTrx"))
                        .USRDEFND1 = CDBNull(.USRDEFND1, oRowLot("USRDEFND1"))
                        .USRDEFND2 = CDBNull(.USRDEFND2, oRowLot("USRDEFND2"))
                        .USRDEFND3 = CDBNull(.USRDEFND3, oRowLot("USRDEFND3"))
                        .USRDEFND4 = CDBNull(.USRDEFND4, oRowLot("USRDEFND4"))
                        .USRDEFND5 = CDBNull(.USRDEFND5, oRowLot("USRDEFND5"))
 
                        'Data access code to delete the line that we just used from DDtaPopRcptLotInsert
                        SPs.dd_DDtaPopRcptLotInsert_DEL_byID(oRow("RowID")).execute()
 
                        'add the line to the POPReceivingsType object
                        ReDim Preserve oPOPReceivingsType.taPopRcptLotInsert_Items(intDistLineCount)
                        oPOPReceivingsType.taPopRcptLotInsert_Items(intDistLineCount) = otaPopRcptLotInsert
                        intDistLineCount += 1
 
                    End With
                Next
 
            End With
        Next
 
        '=======================================================================
        'header
        '=======================================================================
        'create the eConnect header class
        Dim otaPopRcptHdrInsert As New Microsoft.Dynamics.GP.eConnect.Serialization.taPopRcptHdrInsert
 
        'Populate a datatable with the information for the header table
        Dim oDTHeader As DataTable = SPs.dd_DDtaPopRcptHdrInsert_SEL_byID2(POPRCTNM, POPTYPE).getTable
 
        'assign the header data to the eConnect document
        With otaPopRcptHdrInsert
            'populate the object. If the field in the table is null, then assign the field to itself. Otherwise, assign the value
            .POPRCTNM = cdbnull(.POPRCTNM, oDTHeader.Rows(0)("POPRCTNM"))
            .POPTYPE = cdbnull(.POPTYPE, oDTHeader.Rows(0)("POPTYPE"))
            .VNDDOCNM = cdbnull(.VNDDOCNM, oDTHeader.Rows(0)("VNDDOCNM"))
            .receiptdate = cdbnull(.receiptdate, oDTHeader.Rows(0)("receiptdate"))
            .ACTLSHIP = cdbnull(.ACTLSHIP, oDTHeader.Rows(0)("ACTLSHIP"))
            .BACHNUMB = cdbnull(.BACHNUMB, oDTHeader.Rows(0)("BACHNUMB"))
            .VENDORID = cdbnull(.VENDORID, oDTHeader.Rows(0)("VENDORID"))
            .VENDNAME = cdbnull(.VENDNAME, oDTHeader.Rows(0)("VENDNAME"))
            .SUBTOTAL = cdbnull(.SUBTOTAL, oDTHeader.Rows(0)("SUBTOTAL"))
            If Not oDTHeader.Rows(0)("SUBTOTAL") Is System.DBNull.Value Then
                .SUBTOTALSpecified = 1
            End If
            .TRDISAMT = cdbnull(.TRDISAMT, oDTHeader.Rows(0)("TRDISAMT"))
            If Not oDTHeader.Rows(0)("TRDISAMT") Is System.DBNull.Value Then
                .TRDISAMTSpecified = 1
            End If
            .FRTAMNT = cdbnull(.FRTAMNT, oDTHeader.Rows(0)("FRTAMNT"))
            .MISCAMNT = cdbnull(.MISCAMNT, oDTHeader.Rows(0)("MISCAMNT"))
            .TAXAMNT = cdbnull(.TAXAMNT, oDTHeader.Rows(0)("TAXAMNT"))
            .TEN99AMNT = cdbnull(.TEN99AMNT, oDTHeader.Rows(0)("TEN99AMNT"))
            .PYMTRMID = cdbnull(.PYMTRMID, oDTHeader.Rows(0)("PYMTRMID"))
            .DSCPCTAM = cdbnull(.DSCPCTAM, oDTHeader.Rows(0)("DSCPCTAM"))
            If Not oDTHeader.Rows(0)("DSCPCTAM") Is System.DBNull.Value Then
                .DSCPCTAMSpecified = 1
            End If
            .DSCDLRAM = cdbnull(.DSCDLRAM, oDTHeader.Rows(0)("DSCDLRAM"))
            If Not oDTHeader.Rows(0)("DSCDLRAM") Is System.DBNull.Value Then
                .DSCDLRAMSpecified = 1
            End If
            .DISAVAMT = cdbnull(.DISAVAMT, oDTHeader.Rows(0)("DISAVAMT"))
            If Not oDTHeader.Rows(0)("DISAVAMT") Is Nothing Then
                .DISAVAMTSpecified = True
            End If
            .REFRENCE = cdbnull(.REFRENCE, oDTHeader.Rows(0)("REFRENCE"))
            .USER2ENT = cdbnull(.USER2ENT, oDTHeader.Rows(0)("USER2ENT"))
            .VCHRNMBR = cdbnull(.VCHRNMBR, oDTHeader.Rows(0)("VCHRNMBR"))
            .Tax_Date = cdbnull(.Tax_Date, oDTHeader.Rows(0)("Tax_Date"))
            .TIME1 = cdbnull(.TIME1, oDTHeader.Rows(0)("TIME1"))
            .WITHHAMT = cdbnull(.WITHHAMT, oDTHeader.Rows(0)("WITHHAMT"))
            .TXRGNNUM = cdbnull(.TXRGNNUM, oDTHeader.Rows(0)("TXRGNNUM"))
            .AUTOCOST = cdbnull(.AUTOCOST, oDTHeader.Rows(0)("AUTOCOST"))
            .TAXSCHID = cdbnull(.TAXSCHID, oDTHeader.Rows(0)("TAXSCHID"))
            .Purchase_Freight_Taxable = cdbnull(.Purchase_Freight_Taxable, oDTHeader.Rows(0)("Purchase_Freight_Taxable"))
            .Purchase_Misc_Taxable = cdbnull(.Purchase_Misc_Taxable, oDTHeader.Rows(0)("Purchase_Misc_Taxable"))
            .FRTSCHID = cdbnull(.FRTSCHID, oDTHeader.Rows(0)("FRTSCHID"))
            .MSCSCHID = CDBNull(.MSCSCHID, oDTHeader.Rows(0)("MSCSCHID"))
            .FRTTXAMT = cdbnull(.FRTTXAMT, oDTHeader.Rows(0)("FRTTXAMT"))
            .MSCTXAMT = cdbnull(.MSCTXAMT, oDTHeader.Rows(0)("MSCTXAMT"))
            .BCKTXAMT = cdbnull(.BCKTXAMT, oDTHeader.Rows(0)("BCKTXAMT"))
            .BackoutTradeDiscTax = cdbnull(.BackoutTradeDiscTax, oDTHeader.Rows(0)("BackoutTradeDiscTax"))
            .SHIPMTHD = cdbnull(.SHIPMTHD, oDTHeader.Rows(0)("SHIPMTHD"))
            .USINGHEADERLEVELTAXES = cdbnull(.USINGHEADERLEVELTAXES, oDTHeader.Rows(0)("USINGHEADERLEVELTAXES"))
            .CREATEDIST = cdbnull(.CREATEDIST, oDTHeader.Rows(0)("CREATEDIST"))
            .CURNCYID = cdbnull(.CURNCYID, oDTHeader.Rows(0)("CURNCYID"))
            .XCHGRATE = cdbnull(.XCHGRATE, oDTHeader.Rows(0)("XCHGRATE"))
            .RATETPID = cdbnull(.RATETPID, oDTHeader.Rows(0)("RATETPID"))
            .EXPNDATE = cdbnull(.EXPNDATE, oDTHeader.Rows(0)("EXPNDATE"))
            .EXCHDATE = cdbnull(.EXCHDATE, oDTHeader.Rows(0)("EXCHDATE"))
            .EXGTBDSC = cdbnull(.EXGTBDSC, oDTHeader.Rows(0)("EXGTBDSC"))
            .EXTBLSRC = cdbnull(.EXTBLSRC, oDTHeader.Rows(0)("EXTBLSRC"))
            .RATEEXPR = cdbnull(.RATEEXPR, oDTHeader.Rows(0)("RATEEXPR"))
            .DYSTINCR = cdbnull(.DYSTINCR, oDTHeader.Rows(0)("DYSTINCR"))
            .RATEVARC = cdbnull(.RATEVARC, oDTHeader.Rows(0)("RATEVARC"))
            .TRXDTDEF = cdbnull(.TRXDTDEF, oDTHeader.Rows(0)("TRXDTDEF"))
            .RTCLCMTD = cdbnull(.RTCLCMTD, oDTHeader.Rows(0)("RTCLCMTD"))
            .PRVDSLMT = cdbnull(.PRVDSLMT, oDTHeader.Rows(0)("PRVDSLMT"))
            .DATELMTS = cdbnull(.DATELMTS, oDTHeader.Rows(0)("DATELMTS"))
            .DUEDATE = cdbnull(.DUEDATE, oDTHeader.Rows(0)("DUEDATE"))
            .DISCDATE = cdbnull(.DISCDATE, oDTHeader.Rows(0)("DISCDATE"))
            .NOTETEXT = cdbnull(.NOTETEXT, oDTHeader.Rows(0)("NOTETEXT"))
            .VADCDTRO = cdbnull(.VADCDTRO, oDTHeader.Rows(0)("VADCDTRO"))
            .CASHAMNT = cdbnull(.CASHAMNT, oDTHeader.Rows(0)("CASHAMNT"))
            .CAMCBKID = cdbnull(.CAMCBKID, oDTHeader.Rows(0)("CAMCBKID"))
            .CDOCNMBR = cdbnull(.CDOCNMBR, oDTHeader.Rows(0)("CDOCNMBR"))
            .CAMTDATE = cdbnull(.CAMTDATE, oDTHeader.Rows(0)("CAMTDATE"))
            .CAMPMTNM = cdbnull(.CAMPMTNM, oDTHeader.Rows(0)("CAMPMTNM"))
            .CHEKAMNT = cdbnull(.CHEKAMNT, oDTHeader.Rows(0)("CHEKAMNT"))
            .CHAMCBID = cdbnull(.CHAMCBID, oDTHeader.Rows(0)("CHAMCBID"))
            .CHEKNMBR = cdbnull(.CHEKNMBR, oDTHeader.Rows(0)("CHEKNMBR"))
            .CHEKDATE = cdbnull(.CHEKDATE, oDTHeader.Rows(0)("CHEKDATE"))
            .CAMPYNBR = cdbnull(.CAMPYNBR, oDTHeader.Rows(0)("CAMPYNBR"))
            .CRCRDAMT = cdbnull(.CRCRDAMT, oDTHeader.Rows(0)("CRCRDAMT"))
            .CARDNAME = cdbnull(.CARDNAME, oDTHeader.Rows(0)("CARDNAME"))
            .CCRCTNUM = cdbnull(.CCRCTNUM, oDTHeader.Rows(0)("CCRCTNUM"))
            .CRCARDDT = cdbnull(.CRCARDDT, oDTHeader.Rows(0)("CRCARDDT"))
            .CCAMPYNM = cdbnull(.CCAMPYNM, oDTHeader.Rows(0)("CCAMPYNM"))
            .DISTKNAM = cdbnull(.DISTKNAM, oDTHeader.Rows(0)("DISTKNAM"))
            .RequesterTrx = cdbnull(.RequesterTrx, oDTHeader.Rows(0)("RequesterTrx"))
            .USRDEFND1 = cdbnull(.USRDEFND1, oDTHeader.Rows(0)("USRDEFND1"))
            .USRDEFND2 = cdbnull(.USRDEFND2, oDTHeader.Rows(0)("USRDEFND2"))
            .USRDEFND3 = cdbnull(.USRDEFND3, oDTHeader.Rows(0)("USRDEFND3"))
            .USRDEFND4 = cdbnull(.USRDEFND4, oDTHeader.Rows(0)("USRDEFND4"))
            .USRDEFND5 = cdbnull(.USRDEFND5, oDTHeader.Rows(0)("USRDEFND5"))
 
            'Data access code to delete the line from the header table
            SPs.dd_DDtaPopRcptHdrInsert_DEL_byID2(POPRCTNM, POPTYPE).execute()
        End With
 
        'assign the document to the eConnectType
        oPOPReceivingsType.taPopRcptHdrInsert = otaPopRcptHdrInsert
        ReDim oeConnectType.POPReceivingsType(0)
        oeConnectType.POPReceivingsType(0) = oPOPReceivingsType
 
        'send the transaction
        'the eConnectFunctions class is documented here:http://dyndeveloper.com/thread.aspx?Threadid=1117
        strResult = oeConnectFunctions.CreateTransactionEntity(oeConnectType)
 
    Catch ex As Exception
        Dim strMessage = ex.Message
        Throw New Exception(strMessage)
    End Try
 
    Return strResult
End Function
 

 


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