MoveFirst, MoveNext generate errors; EOF always False

SUGGESTED

Hi All,

Please advise - seeing this with our customer - live database and ABC sample database throw the following exceptions while navigating through line items distribution:

MoveFirst: <Error: 0 in Method MOVEFIRST>

MoveNext: <Error: 0 in Method MOVENEXT>; <Error: 542 in Method MOVENEXT>

It is seen with invoices; sales orders are ok. We use an SO_Shipping_UI object's oLines.oDistribution. We cannot replicate it in our environment, so it must be something specific to their installation.

There is a corresponding record in the SO_InvoiceTierDistribution table but the first call of MoveFirst returns the above error.

What's worse is that we also have an EOF check as the loop condition which does not raise exception but always returns False, meaning we got an infinite loop.

Any advice would be very much appreciated,

thanks,

Alex

  • 0
    SUGGESTED

    Update.

    Sorry for the troubles,

    The solution was to explicitly call SO_Shipping_bus / oLines.nMoveFirst after we selected the document with SetKey, before any navigation through oLines.oDistribution. Our code is really complex so it took me a while.

    Still not sure why it was impossible to replicate it in house. My understanding is that some other operation was allocating the data set explicitly, but not in the client case :-(.

    Any insights would still be appreciated.

    Thanks,

    Alex

    V-Technologies

  • 0 in reply to postnik706

    Putting in the script I used for tests. The issue is resolved by uncommenting "o.oLines.nMoveFirst".

    "o.oLines.oDistribution.nMoveFirst" returns "<Error: 0 in Method MOVEFIRST>" on the customer's machine.

    The problem was confirmed with versions 14.0.2.20140422/Sage 100 ERP 2013 and 14.0.2.20140422/Sage 100 ERP 2014.

    Same versions in our QA / Dev environment does not show such behavior.

    Thanks.

    Sub errchk(r, desc)
        if (r = 0) then
            MsgBox(desc & ": " & o.sLastErrorMsg)
            oss.nCleanup()
            oss.DropObject()
            Set oss = Nothing
            WScript.Quit
        end if
    end sub

    ' MAS dll infinite loop investigation.

    Set oScript = CreateObject ("ProvideX.Script")

    'Get the ODBC path for the last accessed installation of MAS 90/200
    Const HKEY_CURRENT_USER = &H80000001
    Set oReg = GetObject("winmgmts:\\.\root\default:StdRegProv")
    oReg.GetExpandedStringValue HKEY_CURRENT_USER,"Software\ODBC\ODBC.INI\SOTAMAS90","Directory",PathRoot
    PathHome = PathRoot & "\Home"
    Set oReg = Nothing

    'Init
    oScript.Init(PathHome)

    'The Session object must be the first MAS 90 object created
    Set oSS = oScript.NewObject("SY_Session")

    ' Set the user
    r = oSS.nLogon()
    If r=0 Then
        '''''''''''''''''''''''
        ' Enter: username, password
        user = Trim(InputBox("Enter User Name", "", "alex"))
        password = Trim(InputBox("Enter Password", "", "alex"))
        retVAL = oSS.nSetUser(User,Password)

        r = oss.nSetUser(user, password)
    End If

    ' company, module date and module for the Session
    company = Trim(InputBox("Enter Company", "", "ABC"))
    r = oss.nsetcompany(company)

    invoiceNumber = trim(InputBox("Enter Invoice Number", "", "0100349"))

    sDate = oSS.sModuleDate
    if sDate = "" then
      sDate = Year(Date) & Right("0" & Month(Date), 2) & Right("0" & Day(Date), 2)      
    end if  
    retVAL = oSS.nSetDate("S/O",sDate)
    r = oSS.nSetModule("S/O")

    oSEC = oSS.nSetProgram(oSS.nLookupTask("SO_Shipping_UI"))
    Set o = oScript.NewObject("SO_Shipping_bus", oSS)

    '''''''''''''''''''''''
    ' Invoice Number
    InvoiceNo = invoiceNumber

    r = o.nSetKey(InvoiceNo)
    errchk r, "SetKey Error"

    'o.oLines.nMoveFirst
    r = o.oLines.oDistribution.nMoveFirst
    if (r = 0) then
        MsgBox("MoveFirst" & ": " & o.sLastErrorMsg)
    end if
    MsgBox("MoveFirst resulted in: " & r)
    do while (o.oLines.oDistribution.nEOF = 0)
        o.oLines.oDistribution.nMoveNext
    loop

    ' Done with the Invoice object
    r = o.DropObject()
    o = 0

    Wscript.Echo "DONE"

    oss.nCleanup()        ' Call Cleanup() before dropping the Session Object
    oss.DropObject()
    Set oss = Nothing
    WScript.Quit