IM_Transaction - SetKey Failed ERP MAS 200 SQL (Version 4.50.7.0)

Hi All,

Everytime I try to set the key, failed but its working on other MAS Version (Sage 100 Standard ERP 2015 - Version 5.20.3 - Providex)

retVAL = oIM_TE.nSelectNewBatch(BatchNo, "N", "Created by Auto Import")  '--> Good

TransactionType = "6"

retVAL = oIM_TE.nSetValue("TransactionType$", TransactionType) '--> Good
retVAL = oIM_TE.nGetNextEntryNo(NextEntryNo) '--> Good

retVAL = oIM_TE.nSetKeyValue("TransactionType$", TransactionType.ToString()) '--> Good
retVAL = oIM_TE.nSetKeyValue("EntryNo$", NextEntryNo.ToString()) '--> Good
retVAL = oIM_TE.nSetKey() 'This Line is failing. - it created the record and return 0

Error '<<== sLastErrorMsg = "Missing or invalid Header"; sLastErrorNum = "CI_LineEntry_Header"

if I keep going I can add a new line but when I tried to save (retVAL = oIM_TE.nWrite()) it I get "its not Editable"

any thoughts!

 

Thanks in advanced 

 

 

  • 0

    I tried this using vbscript and the below code worked fine. Couple notes, I've already set oUI as an object and I'm using a transaction type of 1 (to get around the item i tested with wanting to be distributed when i tried an adjustment).

    sBatch = ""
    retval = oIM_Transaction_bus.nSelectBatch(sBatch)
    retval = oUI.sMessageBox("", "Select Batch: " & retval & vbcrlf & oIM_Transaction_bus.sLastErrorMsg & vbcrlf & sBatch)
    sTransactionType = ""
    sTransactionType = "1"
    retval = oIM_Transaction_bus.nSetValue("TransactionType$", sTransactionType)
    sNextEntryNo = ""
    retval = oIM_Transaction_bus.nGetNextEntryNo(sNextEntryNo)
    retval = oUI.sMessageBox("", "Get Next Entry No: " & retval & vbcrlf & oIM_Transaction_bus.sLastErrorMsg & vbcrlf & sNextEntryNo)
    retval = oIM_Transaction_bus.nSetKeyValue("TransactionType$", sTransactionType)
    retval = oIM_Transaction_bus.nSetKeyValue("EntryNo$", sNextEntryNo)
    retval = oIM_Transaction_bus.nSetKey()
    retval = oUI.sMessageBox("", "Set Header Key: " & retval & vbcrlf & oIM_Transaction_bus.sLastErrorMsg)
    set oIM_TransactionDetail_bus = oIM_Transaction_bus.oLines
    retval = oIM_TransactionDetail_bus.nAddLine()
    retval = oUI.sMessageBox("", "Add Line: " & retval & vbcrlf & oIM_TransactionDetail_bus.sLastErrorMsg)
    retval = oIM_TransactionDetail_bus.nSetValue("ItemCode$", "012")
    retval = oIM_TransactionDetail_bus.nSetValue("TransactionQty", 1.0)
    retval = oIM_TransactionDetail_bus.nWrite()
    retval = oUI.sMessageBox("", "Line Write: " & retval & vbcrlf & oIM_TransactionDetail_bus.sLastErrorMsg)
    retval = oIM_Transaction_bus.nWrite()
    retval = oUI.sMessageBox("", "Header Write: " & retval & vbcrlf & oIM_Transaction_bus.sLastErrorMsg)
    retval = oIM_Transaction_bus.nClear()

    Here's a couple things to try.

    Make sure you are declaring the transaction type and next entry number variables as strings before you use them in the sage methods, see my example above where i have sTransactionType = "" and sNextEntryNo = "".

    Try replacing TransactionType.ToString() with just TransactionType, do the same for the entry no.

    Make sure the user you are logging in with has security rights to perform the transaction type.

    Try checking the retval and the last error msg after "retVAL = oIM_TE.nSetValue("TransactionType$", TransactionType) '--> Good" and after "retVAL = oIM_TE.nGetNextEntryNo(NextEntryNo) '--> Good"