Error -5002 when I insert quotation with DI API

Hello everybody.
I come back to this project but I have always the same problem. I have upgrade a database from version 6.5 to 2004 patch 14.
Now I want to insert a new quotation with DI API.
But I have always the error -5002 in ErrCode variable.
Here the code:
    On Error GoTo Event_Handler
    Dim codcli, str, sel As String
    str = "Select CardCode From OCRD Where CardName = '" & codice_fiera & "' AND CardType = 'C'"
    oRS.DoQuery str
    codcli = CStr(oRS.Fields.Item(0).Value)
    Dim i As Integer
    Dim flag As Boolean
    Dim RetVal, RetValOrd As Long
    RetVal = 1
    RetValOrd = 1
    flag = True
    Set vQuotation = pCompany.GetBusinessObject(oQuotations)
    Dim NumOrd As Long
    Dim CodArt As String
    For i = 1 To N
            Set oEditText = oMatrice.Columns("col1").Cells.Item(i).Specific
            sel = oEditText.String
            If (sel <> "") Then
                If (flag) Then
                    vQuotation.Series = 1011
                    vQuotation.CardCode = codcli
                    vQuotation.HandWritten = tNO
                    vQuotation.DocDate = Date
                    vQuotation.DocDueDate = Date
                    Dim tipo_ord As String
                    Set oEditText = oMatrice.Columns("col11").Cells.Item(i).Specific
                    tipo_ord = CStr(oEditText.String)
                    str = "Select Code From [@CAUSALI] Where Name = '" & tipo_ord & "'"
                    oRS.DoQuery str
                    vQuotation.UserFields("U_tpor").Value = CStr(oRS.Fields.Item(0).Value)
                    flag = False
                End If
                    Set oEditText = oMatrice.Columns("col2").Cells.Item(i).Specific
                    CodArt = CStr(oEditText.String)
                    vQuotation.Lines.ItemCode = oEditText.String
                    Set oEditText = oMatrice.Columns("col3").Cells.Item(i).Specific
                    vQuotation.Lines.ItemDescription = oEditText.String
                    Set oEditText = oMatrice.Columns("col4").Cells.Item(i).Specific
                    vQuotation.Lines.Quantity = oEditText.String
                    Dim Qta As Double
                    Qta = Val(oEditText.String)
                    vQuotation.Lines.UserFields("U_qta_cons").Value = Qta
                    vQuotation.Lines.UserFields("U_tipo").Value = codice_fiera
                    Set oEditText = oMatrice.Columns("col9").Cells.Item(i).Specific
                    vQuotation.Lines.UserFields("U_Inizio").Value = oEditText.String
                    Set oEditText = oMatrice.Columns("col10").Cells.Item(i).Specific
                    vQuotation.Lines.UserFields("U_Fine").Value = oEditText.String
                    str = "ordine nr. "
                    Set oEditText = oMatrice.Columns("col6").Cells.Item(i).Specific
                    NumOrd = Val(oEditText.String)
                    str = str & oEditText.String
                    Set oEditText = oMatrice.Columns("col5").Cells.Item(i).Specific
                    str = str & " a " & oEditText.String
                    vQuotation.Lines.FreeText = str
                    str = "Select Price, DiscPrcnt, VatGroup, WhsCode From RDR1 Where DocEntry = " & NumOrd & " AND ItemCode = '" & CodArt & "'"
                    oRS.DoQuery str
                    vQuotation.Lines.Price = Val(oRS.Fields.Item(0).Value)
                    vQuotation.Lines.DiscountPercent = Val(oRS.Fields.Item(1).Value)
                    vQuotation.Lines.VatGroup = CStr(oRS.Fields.Item(2).Value)
                    vQuotation.Lines.WarehouseCode = CStr(oRS.Fields.Item(3).Value)
                    vQuotation.Lines.Add
                    str = "Select LineNum, U_qta_cons From RDR1 Where DocEntry = " & NumOrd & " And ItemCode = '" & CodArt & "'"
                    oRS.DoQuery str
                    Dim RigaNum As Long
                    RigaNum = oRS.Fields.Item(0).Value
                    Dim QtaCons As Double
                    QtaCons = Val(oRS.Fields.Item(1).Value) + Qta
                    str = "Update RDR1 Set U_qta_cons = " & QtaCons & "Where DocEntry = " & NumOrd & "And LineNum = " & RigaNum
                    oRS.DoQuery str
            End If
    Next
    If (Not flag) Then
        RetVal = vQuotation.Add
    End If
    Dim ErrCode As Long
    Dim ErrMsg As String
    If RetVal <> 0 Then
        pCompany.GetLastError ErrCode, ErrMsg
        str = "Offerta non generata!" & ErrCode & " " & ErrMsg
    Else
        str = "Offerta generata correttamente!"
    End If
    oMessaggio.Caption = str
Event_Handler:
    If Err.Number <> 0 Then
        SBOApplication.MessageBox (Err.Description)
    End If
Thanks for your help.
Regards,
Veronica Vezzali

Hi Veronica,
Be sure that you have created a posting period for 2005 (current year). I.e. Administration | System Initialisation | General Settings | Posting Periods.
After that you should be able to connect with your DI.
Marcel

Similar Messages

  • TS1424 error 5002 when trying to purchase with credit card?

    Need to know what error 5002 means when trying to purchase music off of wish list?

    This alert is often the result of an issue with verifying your billing.
    Quit iTunes.
    Open iTunes.
    Test the issue.
    If it persists, sign in to store.apple.com using your iTunes account
    Click on Change account information
    Modify or remove your credit card information.
    Click Continue.
    Test the issue.

  • Error -5002 when adding a UDF, with B1 9.1

    Hello,
    in the past I wrote some addons for SAP B1 9.0 and worked well.
    Now I just upgraded our SAP B1 32-bit client from 9.0 to 9.1.
    If I try to run any of my addons and I get error code -5002, with description "Nessun record dati" ("No data records" in English).
    It occures in this piece of code that creates UDFs, when doing Add() the result is -5002 instead of 0:
    UserFieldsMD md = (UserFieldsMD)Global.oCompany.GetBusinessObject(BoObjectTypes.oUserFields);
    string realFieldName = "U_NS_MYFIELD";
    // Setting the Field's properties
    md.TableName = "RDR1";
    md.Name = "NS_MYFIELD";
    md.Description = "My field";
    md.Type = BoFieldTypes.db_Alpha;
    md.SubType = BoFldSubTypes.st_None;
    md.EditSize = 254;
    md.Mandatory = BoYesNoEnum.tNO;
    // Adding the Field to the Table
    int result = md.Add();
    Global.ReleaseComObject(md);
    This occures both keeping the old 9.0 version of SAPbobsCOM.dll and changing it to the new 9.1 version...
    Maybe the mechanism for creating UDFs has been changed? The reference (REFDI.chm) doesn't tell it.
    Kind regards

    This function is how I create UDF. I'm using it since SAP 8.8
    Function CreateUDF(ByVal TableName As String, ByVal FieldName As String, ByVal FieldDescription As String, Optional ByVal UDFLength As Integer = 10, Optional ByVal FieldType As SAPbobsCOM.BoFieldTypes = SAPbobsCOM.BoFieldTypes.db_Alpha, Optional ByVal DefaultValue As Object = "", Optional ByVal ShowMessage As Boolean = False, Optional ByVal dtValidValues As Data.DataTable = Nothing, Optional ByVal LinkedTable As String = "", Optional ByVal FieldSubType As SAPbobsCOM.BoFldSubTypes = Nothing, Optional ByVal isMandatory As SAPbobsCOM.BoYesNoEnum = SAPbobsCOM.BoYesNoEnum.tNO, Optional ByVal isUpdateExisting As Boolean = False) As Boolean
            Try
                Dim FieldID As Integer = GetUDFId(TableName, FieldName)
                oRecset = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
                If Not IsNothing(oRecset) Then
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecset)
                    oRecset = Nothing
                    GC.Collect()
                End If
                Dim oUserFields As SAPbobsCOM.UserFieldsMD
                oUserFields = oDICompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
                Dim isExists As Boolean = False
                'LSC 10/20/2013
                If Not FieldID = -1 Then 'oUserFields.GetByKey(TableName, FieldID) Then
                    '  oUserFields.Remove()
                    ' If Not isUpdateExisting Then Return True
                    Return True
                    'oUserFields.Remove()
                End If
                With oUserFields
                    If Not isExists Then
                        .TableName = TableName
                        .Name = FieldName
                        .Description = FieldDescription
                        .Type = FieldType
                    End If
                    .EditSize = UDFLength
                    .Mandatory = isMandatory
                    Select Case oUserFields.Type
                        Case 4
                            .SubType = FieldSubType
                    End Select
                    If FieldType = SAPbobsCOM.BoFieldTypes.db_Alpha Or FieldType = SAPbobsCOM.BoFieldTypes.db_Float Or FieldType = SAPbobsCOM.BoFieldTypes.db_Numeric Or FieldType = SAPbobsCOM.BoFieldTypes.db_Date Then
                        If Not DefaultValue = "" Then .DefaultValue = DefaultValue
                    End If
                    If Not LinkedTable = "" Then .LinkedTable = LinkedTable
                    If Not IsNothing(dtValidValues) Then
                        For Loops As Integer = 0 To dtValidValues.Rows.Count - 1
                            .ValidValues.Value = dtValidValues.Rows(Loops).Item("Value")
                            .ValidValues.Description = dtValidValues.Rows(Loops).Item("Description")
                            If Loops <= dtValidValues.Rows.Count - 1 Then .ValidValues.Add()
                        Next
                    End If
                    If isExists Then
                        If Not .Update = 0 Then
                            If ShowMessage Then SetMessage(oDICompany.GetLastErrorDescription)
                            Return False
                        End If
                    Else
                        If Not .Add = 0 Then
                            If ShowMessage Then SetMessage(oDICompany.GetLastErrorDescription)
                            Return False
                        End If
                    End If
                End With
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUserFields)
                oUserFields = Nothing
                GC.Collect()
                Return True
            Catch ex As Exception
                SetMessage(ex)
                Return False
            End Try
        End Function

  • Error 5002 when trying to login with apple ID.

    Just had a new HD installed in my 4year old MacbookPro. Need yo update some of my Apps. Not sure what to do.

    Are you getting this when trying to access the App Store?
    Connecting to App Store Problems

  • HT3275 Since updating OS to Mountain Lion from leopard, I get the following error message when trying to backup with time machine on external drive.  Could not complete backup to media share.  The network backup disk does not support the required AFP feat

    Since updating OS to Mountain Lion from leopard, I get the following error message when trying to backup with time machine on external drive.  "Could not complete backup to media share.  The network backup disk does not support the required AFP features."  What are AFP features and how do I get Time Machine to backup to my current external backup?

    This means that your NAS does not support the required encryption. Update your NAS to the latest firmware or ditch it and buy a Time Capsule (they are the most reliable when using TM).

  • Getting error 789 when trying to connect with a PC remotely via VPN

    When we set up the VPN we are getting a Error 789 when trying to connect with a PC. Any suggestions would be appreciated.

    The utilities, provided on the CD, are not required for the PC to access the Internet through the 802.11n AirPort Extreme Base Station (AEBSn). They are only necessary for administering the base station.
    If your PC is currently configured as a DHCP client, it shouldn't have any issues connecting by Ethernet. The AEBSn will assign the appropriate IP addresses required for connectivity to the Internet ... just like it does for wireless clients.

  • I have a Macbook Pro that I have just renewed and transferred over my old hard drive (also from a Macbook Pro). Now when I turn on the computer and ITunes opens I get error (-50) and then error 5002 when I try to sign in to ITunes Store - Help!

    I have a Macbook Pro that I have just renewed and transferred over my old hard drive (also from a Macbook Pro). Now when I turn on the computer and ITunes opens I get error (-50) and then error 5002 when I try to sign in to ITunes Store - Help!
    My dealer has tried and failed (twice) to correct this and I have tried deleting the two items in the Itunes folder but no luck!

    were you able to get help on this?  I need help on error 5002 as well.  thank you

  • I get error 5002 when trying to redeem gift cards , what do I need to do to fix this.

    I get error 5002 when trying to redeem gift cards, what can I do to fix this?

    http://store.apple.com/us
    I have been trying to fix this myself and just found a way tonight. This started happening after I downloaded a new version. I tried several other approaches and was unsuccessful until I was directed to the support website.  I searched for 5002 error.  I chose specific conditions and alert message.  Then chose "Error 5002" which gave a little detail. 
    Basically I had to go to the above site and change my password and some other account information.  It didn't work when I tried in my actual ITUNES application.  I think because my account was so old and they upgraded some security items like stronger passwords etc., so the old stuff was no longer good enough.  I have now redeemed two gift cards.  I hope it helps.

  • I get error 5002 when trying to buy 3.1 software for iPod touch 1st gen

    I get error 5002 when trying to buy 3.1 software for iPod touch 1st gen. 

    That is a paid update you get here:
    Purchasing iOS 3.1 Software Update for iPod touch (1st generation)

  • I keep getting "Error 5002" When I try to buy an album. What do I do?

    I keep getting "Error 5002" When I try to buy an album. What do I do? I already reinstalled iTunes... not sure what this error means or how to be able to buy this album.

    There's some info on your error message number in the Specific Conditions and Alert Messages: (Mac OS X / Windows) section of the following document:
    iTunes: Advanced iTunes Store troubleshooting

  • IPhone 5 error 4005 when trying to update with itunes

    iPhone 5 error 4005 when trying to update with itunes

    Hello mjy75, 
    Thank yoj for using Apple Support Communities. 
    The following article covers error 4005 when updating your iPhone.
    iOS: Restore errors 4005, 4013, and 4014 - Apple Support
    Regards,
    Jeff D. 

  • HT1386 I keep getting error [54] when i try syncing with i tunes, what do i do?

    I keep getting error 54 when i try syncing with itunes. what do i do?

    Maybe here:
    http://att.macrumors.com/showthread.php?t=1362080
    Also try Googling for: itunes error 54

  • F-04: give error message when clearing AP items with payment block key(R)

    Hi all,
    Customer wants to prevent payment for AP items with payment block key(BSEG-ZLSPR) .
    I want system giving error message when doing payment clearning with t-code:F-04.
    How can I realize it ?
    Thanks Grus!
    Lynn

    Please configure the following nodes properly:
    Financial Accounting>>Accounts Receivable and Accounts Payable>>Business Transactions>>Outgoing Payments Global Settings>>Payment Block Reasons>>Define Payment Block Reasons & Define Default Values for Payment Block
    For the error message: You may define a validation in OB28 with the help of ABAP consultant

  • I am continually getting error -69 when syncing iPad Air with latest iOS and iTunes versions. Any suggestions?

    I am continually getting error -69 when syncing iPad Air with latest iOS and iTunes versions. Any suggestions?

    Try Googling "sync without iTunes".
    There are free alternatives and there are not so free alternatives.
    Btw, to check if AVG is causing the problem, you should uninstall AVG and not just "turn it off".
    Also, can you describe how you go about uninstalling a program? For example, how did you "delete" iTunes?

  • What is error 4002 when trying to sync with Itunes match and how do I fix it?

    What is error 4002 when trying to sync with Itunes match and how do I fix it?

    HI
    Read this How to troubleshoot iTunes Match - Apple Support
    Note specifically holding option ket whilst turning off match.
    Jim

Maybe you are looking for