BOI IM Transaction Entry - Error CI_LineEntry_Header 'Missing or invalid Header'

Running what should be a simple Transaction Entry test for BOI.

I can create all the object I need, test for and create the Batch. Set Key values.

But the call to SetKey is continually returning 0. Last Error Text is 'Missing or invalid Header' and Last error num is 'CI_LineEntry_Header'

I've tried both using SetKey with the Key string, and by using SetKeyValue and SetKey empty.

This is on Sage 100 Advanced, 2013
If it makes a difference, we have Multi-Bin from ACS, and Scanfoce product installed.

And yes, the company does allow external access. We test Sales Order creation and Invoice creation all the time.

Our code:

        Dim oPVX, oSS, oIM_TE As Object
        Dim retVal As Integer
        Dim NextEntryNo, TransactionType, sMsg, BatchNo, TransactionDate As String

        Dim SOTAMAS90Key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Sage Software\MAS 90 Business Desktop\Settings")
        Dim InitPath = SOTAMAS90Key.GetValue("MAS90RootDirectory") & "Home"

        oPVX = CreateObject("ProvideX.Script")
        oPVX.Init(InitPath)

        oSS = oPVX.NewObject("SY_Session")
        If Not (CBool(oSS.nLogon())) Then
            If Not CBool(oSS.nSetUser("TU", "12345")) Then
                GoTo CLEANUP2
            End If
        End If

        oSS.nSetCompany("ATT")
        TransactionDate = Now.Year.ToString("D4") & Now.Month.ToString("D2") & Now.Day.ToString("D2")
        oSS.nSetDate("I/M", TransactionDate)
        oSS.nSetModule("I/M")

        retVal = oSS.nSetProgram(oSS.nLookupTask("IM_Transaction_ui"))
        oIM_TE = oPVX.NewObject("IM_Transaction_bus", oSS)

        retVal = oIM_TE.nBatchEnabled
        If retVal = 1 Then
            BatchNo = ""
            retVal = oIM_TE.nSelectNewBatch(BatchNo, "N", "Batch Created by Auto Import")
        End If

        ' TransactionType: Sale=1, Issue=2, Transfer=4, Adjustment=6, Receipt=8
        TransactionType = "6"
        retVal = oIM_TE.nSetValue("TransactionType$", TransactionType)
        NextEntryNo = ""
        retVal = oIM_TE.nGetNextEntryNo(NextEntryNo)
        retVal = oIM_TE.nSetKey(TransactionType & NextEntryNo) 'This Line is failing.
        If retVal = 0 Then
            sMsg = oIM_TE.sLastErrorMsg & Environment.NewLine & oIM_TE.sLastErrorNum
            MessageBox.Show(sMsg) '<<== sLastErrorMsg = "Missing or invalid Header"; sLastErrorNum = "CI_LineEntry_Header"
        End If

        retVal = oIM_TE.nSetKeyValue("TransactionType$", TransactionType)
        retVal = oIM_TE.nSetKeyValue("NextEntryNo$", NextEntryNo)
        retVal = oIM_TE.nSetKey() 'This Line is failing.
        If retVal = 0 Then
            sMsg = oIM_TE.sLastErrorMsg & Environment.NewLine & oIM_TE.sLastErrorNum
            MessageBox.Show(sMsg) '<<== sLastErrorMsg = "Missing or invalid Header"; sLastErrorNum = "CI_LineEntry_Header"
            GoTo CLEANUP1
        End If

        retVal = oIM_TE.nSetValue("TransactionDate$", TransactionDate)
        retVal = oIM_TE.nSetValue("DefaultFromWhseCode$", "100")
        retVal = oIM_TE.nSetValue("Comment$", "test comment")

        retVal = oIM_TE.oLines.nAddLine()
        retVal = oIM_TE.oLines.nSetValue("ItemCode$", "C6400")
        retVal = oIM_TE.oLines.nSetValue("WarehouseCode$", "100")
        retVal = oIM_TE.oLines.nSetValue("TransactionQty", 10)
        retVal = oIM_TE.oLines.nWrite()

        retVal = oIM_TE.nWrite()

CLEANUP1:
        retVal = oIM_TE.DropObject()

CLEANUP2:
        retVal = oSS.nCleanUp()
        retVal = oSS.DropObject()

        oIM_TE = Nothing
        oSS = Nothing
        oPVX = Nothing
  • 0

    retVal = oIM_TE.nSetKeyValue("NextEntryNo$", NextEntryNo)

    should be

    retVal = oIM_TE.nSetKeyValue("EntryNo$", NextEntryNo)

  • 0 in reply to Natasha Chang

    My Apologies... I created this code as a smaller test from my production code. Not sure how that line was mis-typed. But I corrected and ran again to check, this was not the cause of the error I'm seeing :(

    in reality, I test retVal upon each nSetValue, nSetKeyValue and was not seeing any errors.

    Corrected code "retVal = oIM_TE.nGetValue("EntryNo$", NextEntryNo)" still generates the error "Missing or invalid Header" when nSetKey is called.

  • 0 in reply to Mickey Wright
    Hi All,

    I am running the below code on old version of MAS (ProvideX) and its working but If I run the same code on SAGE MAS 200 SQL I get this error "Missing or invalid Header"

    Any thoughts?


    retVal = oIM_TE.nBatchEnabled
    If retVal = 1 Then
    BatchNo = ""
    retVal = oIM_TE.nSelectNewBatch(BatchNo, "N", "Batch Created by Auto Import")
    End If

    ' TransactionType: Sale=1, Issue=2, Transfer=4, Adjustment=6, Receipt=8
    TransactionType = "6"
    retVal = oIM_TE.nSetValue("TransactionType$", TransactionType)
    NextEntryNo = ""
    retVal = oIM_TE.nGetNextEntryNo(NextEntryNo)
    retVal = oIM_TE.nSetKey(TransactionType & NextEntryNo) 'This Line is failing.