cancel
Showing results for 
Search instead for 
Did you mean: 

SAP B1 Goods Receipt Creation Date Error VB.NET syntax for date

rameezraja_vision33
Discoverer
0 Kudos
165

The following code is throwing an error:

Exception has been thrown by the target of an invocation. - Conversion from string "13/11/2020" to type 'Date' is not valid

Code:

<br>Dim HeaderQuery As String ="SELECT top 1 DocDate FROM OIGE WHERE DocNum = 1039"
Dim RetVal As Long
Dim ErrCode As Long
Dim ErrMsg As String
Dim SCVal As Long
Dim SOEntry as String
Dim oRecordSet As SAPbobsCOM.Recordset
Dim lineRecordSet As SAPbobsCOM.Recordset
oRecordSet = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
lineRecordSet = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
oRecordSet.DoQuery(HeaderQuery)
While oRecordSet.EoF = False
    Dim DetailSOQuery As String ="SELECT 'PM1019-2XL'  , 1"
    Dim vSO As SAPbobsCOM.Documents
    vSO = company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry)

    vSO.DocDate = Date.Now.ToString("dd/MM/yyyy")
    lineRecordSet.DoQuery(DetailSOQuery)
    While lineRecordSet.EoF = False
        vSO.Lines.ItemCode = lineRecordSet.Fields.Item(0).Value
        vSO.Lines.Quantity = lineRecordSet.Fields.Item(1).value
        vSO.Lines.Add()
        lineRecordSet.MoveNext()
    End While
    RetVal = vSO.Add
    If RetVal <> 0 Then
        company.GetLastError(ErrCode, ErrMsg)
        application.messagebox(ErrCode & " " & ErrMsg)
    End If
    oRecordSet.MoveNext()
End While

Accepted Solutions (0)

Answers (0)