Skip to Content

Inventory Counting – Multiple Counters DI-API (SBO 9.1) Method

Hi Everybody!!

For those who need to deploy multiple counters in counting inventory documents using DI-API, here I leave a short code and implementation notes.

NOTE: Available for SBO 9.1 versión

        Dim oCS As SAPbobsCOM.CompanyService = oCompany.GetCompanyService()

        Dim oICS As SAPbobsCOM.InventoryCountingsService = oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryCountingsService)

        Dim oICP As SAPbobsCOM.InventoryCountingParams = oICS.GetDataInterface(SAPbobsCOM.InventoryCountingsServiceDataInterfaces.icsInventoryCountingParams)

        ‘//Counting Document DocEntry

        oICP.DocumentEntry = Convert.ToInt64(txtDoc.Text.ToString)

        ‘//Get the Counting Document

        Dim oIC As SAPbobsCOM.InventoryCounting = oICS.Get(oICP)

        ‘//If Document is Multiple Counters Type

        If oIC.CountingType = SAPbobsCOM.CountingTypeEnum.ctMultipleCounters = True Then

            Dim oICLS As SAPbobsCOM.InventoryCountingLines = oIC.InventoryCountingLines

            Dim oICL As SAPbobsCOM.InventoryCountingLine

            Dim iLine As Integer = 0

            Dim iCurrentCounter As Integer

            ‘//Set the Counter User

            ‘//oICL.CounterID = 1 for manager // (OUSR.USERID) or oCompany.UserSignature for DI loged user

            iCurrentCounter = oCompany.UserSignature

            ‘*****************************************************

            ‘NOTE: When Document is Multiple Counters Type

            ‘      oICLS.Count = (Count of Lines * Users Counters)

            ‘*****************************************************

            For i As Integer = 0 To oICLS.Count – 1

                ‘//Set the Line of Counting

                oICL = oICLS.Item(i)

                ‘//Evaluate the Counter User for not repeat user line

                If oICL.CounterID = iCurrentCounter Then

                    oICL.Counted = BoYesNoEnum.tNO

                    ‘//Implement here the same code used for Single Counter Type

                    ‘//…

                    ‘//…

                End If

            Next

        End If

        Try

            oICS.Update(oIC)

            MessageBox.Show(“Counting document updated!”)

        Catch ex As Exception

            Dim ierr As Integer

            Dim serr As String

            oCompany.GetLastError(ierr, serr)

            MessageBox.Show(serr)

        End Try

Best Regards,

Emilio

1 Comment
You must be Logged on to comment or reply to a post.