2 Replies - 169 Views - Last Post: 03 December 2018 - 12:38 AM Rate Topic: -----

#1 Steve7419   User is online

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 19-November 18

Missing operand after '1' operator

Posted 02 December 2018 - 06:46 PM

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
        IsSaveMode = True
        Dim ErrorLogList As ArrayList
        ErrorLogList = New ArrayList(0)

        Try
         
            SBO_Active_Company.StartTransaction()
            Dim oGoodReceipt As SAPbobsCOM.Documents
            Dim _id As String
            Dim oRows() As DataRow
             Dim rowCounter As Integer
            Dim oGoodsReceiptTable As DataTable
            oGoodsReceiptTable = Me.oDtsGoodReceiptProfitCenter.Tables("GoodsReceipt")
            _id = CType(Me.dtgGoodsReceipt.Item(rowCounter, 0), String)

          
            oRows = oGoodsReceiptTable.Select("_id=''" & _id)
        

            For rowCounter = 0 To oRows.Length - 1
                oGoodReceipt = SBO_Active_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry)
                oGoodReceipt.Series = "599"
                oGoodReceipt.DocDate = Date.Now.ToString("yyyy-MM-dd")
              
                oGoodReceipt.Reference2 = "addon"
                oGoodReceipt.Comments = "Imp.GR."
                oGoodReceipt.JournalMemo = "Imp.GR."
      
                oGoodReceipt.Lines.visorder = CType(oRows(rowCounter).Item("_id"), String)
                oGoodReceipt.Lines.ItemCode = CType(oRows(rowCounter).Item("ItemCode"), String)
                oGoodReceipt.Lines.AccountCode = "5113-0002"
                oGoodReceipt.Lines.Quantity = CType(oRows(rowCounter).Item("Qty"), Double)
                 oGoodReceipt.Lines.WarehouseCode = CType(oRows(rowCounter).Item("whse"), String)
                If rowCounter < oRows.Length - 1 Then
                    oGoodReceipt.Lines.Add()
                End If
            Next
            Dim addStatus As Integer
            Dim sErrMsg As String
            sErrMsg = ""
            addStatus = oGoodReceipt.Add
            If addStatus <> 0 Then
                SBO_Active_Company.GetLastError(addStatus, sErrMsg)
                ErrorLogList.Add(_id & " failed." & Chr(13) & Chr(13) & addStatus & " - " & sErrMsg)
                If SBO_Active_Company.InTransaction Then
                    SBO_Active_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
                End If
                Exit Sub
            End If

            If SBO_Active_Company.InTransaction Then
                SBO_Active_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
            End If
            If ErrorLogList.Count > 0 Then
                Dim fileName As String = Logging.WriteToText(ErrorLogList, "SAVE ERROR")
                Dim oFrmLogViewer As frmLogViewer
                oFrmLogViewer = New frmLogViewer
                oFrmLogViewer.AutoLoad = True
                If fileName = "" Then
                    oFrmLogViewer.LoadFromFile = False
                    oFrmLogViewer.TextList = ErrorLogList
                Else
                    oFrmLogViewer.LoadFromFile = True
                    oFrmLogViewer.LogFileName = fileName
                End If
                oFrmLogViewer.ShowDialog()
            Else
                Me.btnSave.Enabled = False
                MessageBox.Show("Goods Receipt Succeed")
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            If SBO_Active_Company.InTransaction Then
                SBO_Active_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
            End If
        End Try
        Me.Cursor = System.Windows.Forms.Cursors.Default
    End Sub




What I have tried:

I tried to change to oRows = oGoodsReceiptTable.Select("_id='1'" & _id) and it worked but only one line of data is created. I have more than one line of data to be created into one document.

I have 6 data. All of the data are imported into one document of an ERP application. I have attached the result and the data source. The file name of result is goodreceipt1.jpg. The data source is goodreceipt2.jpg.

Any help would be great.
thanks

Regards,
Steve

View PostSteve7419, on 02 December 2018 - 06:43 PM, said:

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Me.Cursor = System.Windows.Forms.Cursors.WaitCursor
        IsSaveMode = True
        Dim ErrorLogList As ArrayList
        ErrorLogList = New ArrayList(0)

        Try
         
            SBO_Active_Company.StartTransaction()
            Dim oGoodReceipt As SAPbobsCOM.Documents
            Dim _id As String
            Dim oRows() As DataRow
             Dim rowCounter As Integer
            Dim oGoodsReceiptTable As DataTable
            oGoodsReceiptTable = Me.oDtsGoodReceiptProfitCenter.Tables("GoodsReceipt")
            _id = CType(Me.dtgGoodsReceipt.Item(rowCounter, 0), String)

          
            oRows = oGoodsReceiptTable.Select("_id=''" & _id)
        

            For rowCounter = 0 To oRows.Length - 1
                oGoodReceipt = SBO_Active_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry)
                oGoodReceipt.Series = "599"
                oGoodReceipt.DocDate = Date.Now.ToString("yyyy-MM-dd")
              
                oGoodReceipt.Reference2 = "addon"
                oGoodReceipt.Comments = "Imp.GR."
                oGoodReceipt.JournalMemo = "Imp.GR."
      
                oGoodReceipt.Lines.visorder = CType(oRows(rowCounter).Item("_id"), String)
                oGoodReceipt.Lines.ItemCode = CType(oRows(rowCounter).Item("ItemCode"), String)
                oGoodReceipt.Lines.AccountCode = "5113-0002"
                oGoodReceipt.Lines.Quantity = CType(oRows(rowCounter).Item("Qty"), Double)
                 oGoodReceipt.Lines.WarehouseCode = CType(oRows(rowCounter).Item("whse"), String)
                If rowCounter < oRows.Length - 1 Then
                    oGoodReceipt.Lines.Add()
                End If
            Next
            Dim addStatus As Integer
            Dim sErrMsg As String
            sErrMsg = ""
            addStatus = oGoodReceipt.Add
            If addStatus <> 0 Then
                SBO_Active_Company.GetLastError(addStatus, sErrMsg)
                ErrorLogList.Add(_id & " failed." & Chr(13) & Chr(13) & addStatus & " - " & sErrMsg)
                If SBO_Active_Company.InTransaction Then
                    SBO_Active_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
                End If
                Exit Sub
            End If

            If SBO_Active_Company.InTransaction Then
                SBO_Active_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit)
            End If
            If ErrorLogList.Count > 0 Then
                Dim fileName As String = Logging.WriteToText(ErrorLogList, "SAVE ERROR")
                Dim oFrmLogViewer As frmLogViewer
                oFrmLogViewer = New frmLogViewer
                oFrmLogViewer.AutoLoad = True
                If fileName = "" Then
                    oFrmLogViewer.LoadFromFile = False
                    oFrmLogViewer.TextList = ErrorLogList
                Else
                    oFrmLogViewer.LoadFromFile = True
                    oFrmLogViewer.LogFileName = fileName
                End If
                oFrmLogViewer.ShowDialog()
            Else
                Me.btnSave.Enabled = False
                MessageBox.Show("Goods Receipt Succeed")
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            If SBO_Active_Company.InTransaction Then
                SBO_Active_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack)
            End If
        End Try
        Me.Cursor = System.Windows.Forms.Cursors.Default
    End Sub




What I have tried:

I tried to change to oRows = oGoodsReceiptTable.Select("_id='1'" & _id) and it worked but only one line of data is created. I have more than one line of data to be created into one document.

I have 6 data. All of the data are imported into one document of an ERP application. I have attached the result and the data source. The file name of result is goodreceipt1.jpg. The data source is goodreceipt2.jpg.

Any help would be great.
thanks

Regards,
Steve


The attachment is forgotten. here I attach the files. Thank you.

Attached image(s)

  • Attached Image
  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Missing operand after '1' operator

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14691
  • View blog
  • Posts: 58,718
  • Joined: 12-June 08

Re: Missing operand after '1' operator

Posted 02 December 2018 - 10:30 PM

Read this:
https://www.csharp-e...view-rowfilter/


This doesn't make sense.
19	            oRows = oGoodsReceiptTable.Select("_id=''" & _id)


Say _id variable is 1. That select would be: _id =''1

Doesn't make sense. The select would work similar to a WHERE clause in a SQL query.
Was This Post Helpful? 1
  • +
  • -

#3 Steve7419   User is online

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 24
  • Joined: 19-November 18

Re: Missing operand after '1' operator

Posted 03 December 2018 - 12:38 AM

View Postmodi123_1, on 02 December 2018 - 10:30 PM, said:

Read this:
https://www.csharp-e...view-rowfilter/


This doesn't make sense.
19	            oRows = oGoodsReceiptTable.Select("_id=''" & _id)


Say _id variable is 1. That select would be: _id =''1

Doesn't make sense. The select would work similar to a WHERE clause in a SQL query.


Thank you for your solution. I finally solve it. here is the new code
oRows = oGoodsReceiptTable.Select("[_id] = " & _id)


Regards,
Steve
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1